1
1
buildscript {
2
- ext. jdkVersion = 17
3
- ext. javaClassVersion = 11
2
+ ext. jdkVersionDefault = 17
3
+ ext. javaClassVersionDefault = 11
4
+
5
+ ext. jdkVersion = { p ->
6
+ // If Spring 6 is present, hard dependency on jdk17
7
+ if (p. configurations. any { it. getDependencies(). any{
8
+ (it. getGroup(). equals(" org.springframework" ) && it. getVersion(). startsWith(" 6." ))
9
+ || (it. getGroup(). equals(" org.springframework.boot" ) && it. getVersion(). startsWith(" 3." ) && ! it. getName(). equals(" spring-boot-starter-test" ))
10
+ }}) {
11
+ return 17
12
+ } else {
13
+ // otherwise we can use the preferred default which can be overridden with a property: -PjdkVersionDefault
14
+ return p. hasProperty(' jdkVersionDefault' ) ? Integer . valueOf((String ) p. getProperty(' jdkVersionDefault' )) : ext. jdkVersionDefault
15
+ }
16
+ }
17
+
18
+ ext. javaClassVersion = { p ->
19
+ // If Spring 6 is present, hard dependency on jdk17
20
+ if (p. configurations. any { it. getDependencies(). any{
21
+ (it. getGroup(). equals(" org.springframework" ) && it. getVersion(). startsWith(" 6." ))
22
+ || (it. getGroup(). equals(" org.springframework.boot" ) && it. getVersion(). startsWith(" 3." ) && ! it. getName(). equals(" spring-boot-starter-test" ))
23
+ }}) {
24
+ return 17
25
+ } else {
26
+ // otherwise we can use the preferred default which can be overridden with a property: -PjavaClassVersionDefault
27
+ return p. hasProperty(' javaClassVersionDefault' ) ? Integer . valueOf((String ) p. getProperty(' javaClassVersionDefault' )) : ext. javaClassVersionDefault
28
+ }
29
+ }
4
30
5
31
ext. junitJupiterVersion = ' 5.6.1'
6
32
// Releases: https://github.com/linkedin/rest.li/blob/master/CHANGELOG.md
@@ -217,6 +243,7 @@ project.ext.externalDependency = [
217
243
' springActuator' : " org.springframework.boot:spring-boot-starter-actuator:$springBootVersion " ,
218
244
' swaggerAnnotations' : ' io.swagger.core.v3:swagger-annotations:2.2.15' ,
219
245
' swaggerCli' : ' io.swagger.codegen.v3:swagger-codegen-cli:3.0.46' ,
246
+ ' springBootAutoconfigureJdk11' : ' org.springframework.boot:spring-boot-autoconfigure:2.7.18' ,
220
247
' testng' : ' org.testng:testng:7.8.0' ,
221
248
' testContainers' : ' org.testcontainers:testcontainers:' + testContainersVersion,
222
249
' testContainersJunit' : ' org.testcontainers:junit-jupiter:' + testContainersVersion,
@@ -252,48 +279,56 @@ allprojects {
252
279
}
253
280
}
254
281
255
- if (project. plugins. hasPlugin(' java' )
282
+ /**
283
+ * If making changes to this section also see the sections for pegasus below
284
+ * which use project.plugins.hasPlugin('pegasus')
285
+ **/
286
+ if (! project. plugins. hasPlugin(' pegasus' ) && (project. plugins. hasPlugin(' java' )
256
287
|| project. plugins. hasPlugin(' java-library' )
257
- || project. plugins. hasPlugin(' application' )
258
- || project. plugins. hasPlugin(' pegasus' )) {
288
+ || project. plugins. hasPlugin(' application' ))) {
259
289
260
290
java {
261
291
toolchain {
262
- languageVersion = JavaLanguageVersion . of(jdkVersion)
292
+ languageVersion = JavaLanguageVersion . of(jdkVersion(project) )
263
293
}
264
294
}
265
295
266
296
compileJava {
267
- options. release = javaClassVersion
297
+ options. release = javaClassVersion(project)
268
298
}
299
+
269
300
tasks. withType(JavaCompile ). configureEach {
270
301
javaCompiler = javaToolchains. compilerFor {
271
- languageVersion = JavaLanguageVersion . of(jdkVersion)
302
+ languageVersion = JavaLanguageVersion . of(jdkVersion(project) )
272
303
}
273
304
// Puts parameter names into compiled class files, necessary for Spring 6
274
305
options. compilerArgs. add(" -parameters" )
275
306
}
276
307
277
308
tasks. withType(JavaExec ). configureEach {
278
309
javaLauncher = javaToolchains. launcherFor {
279
- languageVersion = JavaLanguageVersion . of(jdkVersion)
310
+ languageVersion = JavaLanguageVersion . of(jdkVersion(project) )
280
311
}
281
312
}
313
+ }
314
+
315
+ // not duplicated, need to set this outside and inside afterEvaluate
316
+ afterEvaluate {
317
+ /**
318
+ * If making changes to this section also see the sections for pegasus below
319
+ * which use project.plugins.hasPlugin('pegasus')
320
+ **/
321
+ if (! project. plugins. hasPlugin(' pegasus' ) && (project. plugins. hasPlugin(' java' )
322
+ || project. plugins. hasPlugin(' java-library' )
323
+ || project. plugins. hasPlugin(' application' ))) {
282
324
283
- // not duplicated, need to set this outside and inside afterEvaluate
284
- afterEvaluate {
285
325
compileJava {
286
- options. release = javaClassVersion
287
- }
288
- tasks. withType(JavaCompile ). configureEach {
289
- javaCompiler = javaToolchains. compilerFor {
290
- languageVersion = JavaLanguageVersion . of(jdkVersion)
291
- }
326
+ options. release = javaClassVersion(project)
292
327
}
293
328
294
329
tasks. withType(JavaExec ). configureEach {
295
330
javaLauncher = javaToolchains. launcherFor {
296
- languageVersion = JavaLanguageVersion . of(jdkVersion)
331
+ languageVersion = JavaLanguageVersion . of(jdkVersion(project) )
297
332
}
298
333
}
299
334
}
@@ -368,6 +403,30 @@ subprojects {
368
403
dataTemplateCompile externalDependency. annotationApi // support > jdk8
369
404
restClientCompile spec. product. pegasus. restliClient
370
405
}
406
+
407
+ java {
408
+ toolchain {
409
+ languageVersion = JavaLanguageVersion . of(jdkVersion(project))
410
+ }
411
+ }
412
+
413
+ compileJava {
414
+ options. release = javaClassVersion(project)
415
+ }
416
+
417
+ tasks. withType(JavaCompile ). configureEach {
418
+ javaCompiler = javaToolchains. compilerFor {
419
+ languageVersion = JavaLanguageVersion . of(jdkVersion(project))
420
+ }
421
+ // Puts parameter names into compiled class files, necessary for Spring 6
422
+ options. compilerArgs. add(" -parameters" )
423
+ }
424
+
425
+ tasks. withType(JavaExec ). configureEach {
426
+ javaLauncher = javaToolchains. launcherFor {
427
+ languageVersion = JavaLanguageVersion . of(jdkVersion(project))
428
+ }
429
+ }
371
430
}
372
431
373
432
afterEvaluate {
@@ -394,6 +453,16 @@ subprojects {
394
453
dataTemplateCompile externalDependency. annotationApi // support > jdk8
395
454
restClientCompile spec. product. pegasus. restliClient
396
455
}
456
+
457
+ compileJava {
458
+ options. release = javaClassVersion(project)
459
+ }
460
+
461
+ tasks. withType(JavaExec ). configureEach {
462
+ javaLauncher = javaToolchains. launcherFor {
463
+ languageVersion = JavaLanguageVersion . of(jdkVersion(project))
464
+ }
465
+ }
397
466
}
398
467
}
399
468
}
0 commit comments