@@ -30,6 +30,7 @@ defaultTasks 'clean', 'build', 'shadowJar', 'install'
3030def sbeGroup = ' uk.co.real-logic'
3131def sbeVersion = file(' version.txt' ). text. trim()
3232def sbeJavaVersion = JavaVersion . VERSION_1_8
33+ def sbeJavaReleaseVersion = ' 8'
3334
3435group = sbeGroup
3536version = sbeVersion
@@ -138,15 +139,25 @@ subprojects {
138139 checkstyle. toolVersion = ' 8.25'
139140
140141 compileJava {
141- sourceCompatibility = sbeJavaVersion
142- targetCompatibility = sbeJavaVersion
142+ if (JavaVersion . current(). ordinal() >= JavaVersion . VERSION_1_9 . ordinal()) {
143+ options. compilerArgs. addAll([' --release' , sbeJavaReleaseVersion])
144+ }
145+ else {
146+ sourceCompatibility = sbeJavaVersion
147+ targetCompatibility = sbeJavaVersion
148+ }
143149 options. encoding = ' UTF-8'
144150 options. deprecation = true
145151 }
146152
147153 compileTestJava {
148- sourceCompatibility = sbeJavaVersion
149- targetCompatibility = sbeJavaVersion
154+ if (JavaVersion . current(). ordinal() >= JavaVersion . VERSION_1_9 . ordinal()) {
155+ options. compilerArgs. addAll([' --release' , sbeJavaReleaseVersion])
156+ }
157+ else {
158+ sourceCompatibility = sbeJavaVersion
159+ targetCompatibility = sbeJavaVersion
160+ }
150161 options. encoding = ' UTF-8'
151162 options. deprecation = true
152163 }
@@ -206,8 +217,13 @@ project(':sbe-tool') {
206217
207218 compileGeneratedJava {
208219 dependsOn ' generateCodecs'
209- sourceCompatibility = sbeJavaVersion
210- targetCompatibility = sbeJavaVersion
220+ if (JavaVersion . current(). ordinal() >= JavaVersion . VERSION_1_9 . ordinal()) {
221+ options. compilerArgs. addAll([' --release' , sbeJavaReleaseVersion])
222+ }
223+ else {
224+ sourceCompatibility = sbeJavaVersion
225+ targetCompatibility = sbeJavaVersion
226+ }
211227 options. encoding = ' UTF-8'
212228 options. deprecation = true
213229 classpath + = sourceSets. main. runtimeClasspath
@@ -365,8 +381,13 @@ project(':sbe-samples') {
365381
366382 compileGeneratedJava {
367383 dependsOn ' generateCodecs'
368- sourceCompatibility = sbeJavaVersion
369- targetCompatibility = sbeJavaVersion
384+ if (JavaVersion . current(). ordinal() >= JavaVersion . VERSION_1_9 . ordinal()) {
385+ options. compilerArgs. addAll([' --release' , sbeJavaReleaseVersion])
386+ }
387+ else {
388+ sourceCompatibility = sbeJavaVersion
389+ targetCompatibility = sbeJavaVersion
390+ }
370391 options. encoding = ' UTF-8'
371392 options. deprecation = true
372393 classpath + = project(' :sbe-all' ). sourceSets. main. runtimeClasspath
@@ -461,8 +482,13 @@ project(':sbe-benchmarks') {
461482
462483 compileGeneratedJava {
463484 dependsOn ' generateCodecs'
464- sourceCompatibility = ' 1.8'
465- targetCompatibility = ' 1.8'
485+ if (JavaVersion . current(). ordinal() >= JavaVersion . VERSION_1_9 . ordinal()) {
486+ options. compilerArgs. addAll([' --release' , sbeJavaReleaseVersion])
487+ }
488+ else {
489+ sourceCompatibility = sbeJavaVersion
490+ targetCompatibility = sbeJavaVersion
491+ }
466492 options. encoding = ' UTF-8'
467493 options. deprecation = true
468494 classpath + = project(' :sbe-all' ). sourceSets. main. runtimeClasspath
0 commit comments