@@ -4,15 +4,15 @@ plugins {
4
4
id ' java'
5
5
}
6
6
7
- def compilerVersion = Integer . parseInt((String )project. findProperty(' compilerVersion' ) ?: ' 11 ' )
7
+ def compilerVersion = Integer . parseInt((String )project. findProperty(' compilerVersion' ) ?: ' 21 ' )
8
8
def compilerVendor = project. hasProperty(' compilerVendor' ) ? JvmVendorSpec . matching((String )project. property(' compilerVendor' )): null
9
9
10
10
def languageLevel = Integer . parseInt((String )project. findProperty(' languageLevel' ) ?: ' 11' )
11
- def runtimeVersion = Integer . parseInt((String )project. findProperty(' runtimeVersion' ) ?: ' 11 ' )
11
+ def runtimeVersion = Integer . parseInt((String )project. findProperty(' runtimeVersion' ) ?: ' 21 ' )
12
12
def runtimeVendor = project. hasProperty(' runtimeVendor' ) ? JvmVendorSpec . matching((String )project. property(' runtimeVendor' )): null
13
13
14
14
def testLanguageLevel = Integer . parseInt((String )project. findProperty(' testLanguageLevel' ) ?: ' 11' )
15
- def testRuntimeVersion = Integer . parseInt((String )project. findProperty(' testRuntimeVersion' ) ?: ' 11 ' )
15
+ def testRuntimeVersion = Integer . parseInt((String )project. findProperty(' testRuntimeVersion' ) ?: ' 21 ' )
16
16
def testRuntimeVendor = project. hasProperty(' testRuntimeVendor' ) ? JvmVendorSpec . matching((String )project. property(' testRuntimeVendor' )): null
17
17
18
18
if (languageLevel > compilerVersion) {
@@ -79,17 +79,50 @@ tasks.withType(JavaCompile).configureEach {
79
79
options. incremental = true
80
80
options. compilerArgs << ' -parameters'
81
81
82
- if (name == ' compileTestJava' ) {
82
+ if (name == ' compileJava' ) {
83
+ if (compilerVersion != languageLevel) {
84
+ options. release. set languageLevel
85
+ sourceCompatibility = languageLevel
86
+ targetCompatibility = languageLevel
87
+ }
88
+ } else {
89
+ // This assumes that any JavaCompile task _not_ named 'compileJava' wants to target the testLanguageLevel.
90
+ // If this does not hold in the future, we can update this logic.
83
91
if (compilerVersion != testLanguageLevel) {
84
92
options. release. set testLanguageLevel
93
+ sourceCompatibility = testLanguageLevel
94
+ targetCompatibility = testLanguageLevel
85
95
}
86
- } else {
96
+ }
97
+ }
98
+
99
+ tasks. withType(GroovyCompile ). configureEach {
100
+ javaLauncher. set groovyCompilerLauncher
101
+
102
+ options. fork = true
103
+ options. forkOptions. memoryMaximumSize = ' 2G'
104
+ options. encoding = ' UTF-8'
105
+ options. incremental = true
106
+ options. compilerArgs << ' -parameters'
107
+
108
+ if (name == ' compileGroovy' ) {
87
109
if (compilerVersion != languageLevel) {
88
110
options. release. set languageLevel
111
+ sourceCompatibility = languageLevel
112
+ targetCompatibility = languageLevel
113
+ }
114
+ } else {
115
+ // This assumes that any GroovyCompile task _not_ named 'compileGroovy' wants to target the testLanguageLevel.
116
+ // If this does not hold in the future, we can update this logic.
117
+ if (compilerVersion != testLanguageLevel) {
118
+ options. release. set testLanguageLevel
119
+ sourceCompatibility = testLanguageLevel
120
+ targetCompatibility = testLanguageLevel
89
121
}
90
122
}
91
123
}
92
124
125
+
93
126
def createCompilerDirectives = tasks. register(' createCompilerDirectives' ) {
94
127
def compilerDirectivesFile = project. layout. buildDirectory. file(' dh-compiler-directives.txt' )
95
128
def compilerDirectivesText = new JsonBuilder ([{
@@ -199,10 +232,6 @@ tasks.withType(Test).configureEach {
199
232
jvmArgs + = compilerArgs(compilerDirectivesFile. singleFile. path) + [" -XX:VMOptionsFile=${ vmOptionsFile.singleFile.path} " ] + START_OPTS
200
233
}
201
234
202
- tasks. withType(GroovyCompile ). configureEach {
203
- javaLauncher. set groovyCompilerLauncher
204
- }
205
-
206
235
JavaApplication application = extensions. findByType(JavaApplication )
207
236
if (application) {
208
237
application. applicationDistribution. into(' etc' ) {
0 commit comments