1- import java.text.SimpleDateFormat
1+ import net.ltgt.gradle.errorprone.CheckSeverity
2+ import org.jetbrains.kotlin.gradle.dsl.JvmTarget
3+ import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
24
5+ import java.text.SimpleDateFormat
36
47plugins {
58 id ' java'
@@ -12,11 +15,28 @@ plugins {
1215 id " io.github.gradle-nexus.publish-plugin" version " 2.0.0"
1316 id " groovy"
1417 id " me.champeau.jmh" version " 0.7.3"
18+ id " net.ltgt.errorprone" version ' 4.2.0'
19+ //
20+ // Kotlin just for tests - not production code
21+ id ' org.jetbrains.kotlin.jvm' version ' 2.1.21'
1522}
1623
1724java {
1825 toolchain {
19- languageVersion = JavaLanguageVersion . of(11 )
26+ languageVersion = JavaLanguageVersion . of(21 ) // build on 21 - release on 11
27+ }
28+ }
29+
30+ kotlin {
31+ compilerOptions {
32+ apiVersion = KotlinVersion . KOTLIN_2_0
33+ languageVersion = KotlinVersion . KOTLIN_2_0
34+ jvmTarget = JvmTarget . JVM_11
35+ javaParameters = true
36+ freeCompilerArgs = [
37+ ' -Xemit-jvm-type-annotations' ,
38+ ' -Xjspecify-annotations=strict' ,
39+ ]
2040 }
2141}
2242
@@ -97,19 +117,15 @@ jar {
97117 attributes(' Automatic-Module-Name' : ' com.graphqljava' )
98118 }
99119}
100- tasks. withType(GroovyCompile ) {
101- // Options when compiling Java using the Groovy plugin.
102- // (Groovy itself defaults to UTF-8 for Groovy code)
103- options. encoding = ' UTF-8'
104- groovyOptions. forkOptions. memoryMaximumSize = " 4g"
105- }
120+
106121dependencies {
107- implementation ' org.antlr:antlr4-runtime:' + antlrVersion
108122 api ' com.graphql-java:java-dataloader:5.0.0'
109123 api ' org.reactivestreams:reactive-streams:' + reactiveStreamsVersion
110124 api " org.jspecify:jspecify:1.0.0"
111- antlr ' org.antlr:antlr4:' + antlrVersion
125+
126+ implementation ' org.antlr:antlr4-runtime:' + antlrVersion
112127 implementation ' com.google.guava:guava:' + guavaVersion
128+
113129 testImplementation group : ' junit' , name : ' junit' , version : ' 4.13.2'
114130 testImplementation ' org.spockframework:spock-core:2.3-groovy-4.0'
115131 testImplementation ' net.bytebuddy:byte-buddy:1.17.5'
@@ -129,9 +145,17 @@ dependencies {
129145 testImplementation ' org.testng:testng:7.11.0' // use for reactive streams test inheritance
130146 testImplementation " com.tngtech.archunit:archunit-junit5:1.4.1"
131147
148+ antlr ' org.antlr:antlr4:' + antlrVersion
149+
132150 // this is needed for the idea jmh plugin to work correctly
133151 jmh ' org.openjdk.jmh:jmh-core:1.37'
134152 jmh ' org.openjdk.jmh:jmh-generator-annprocess:1.37'
153+
154+ errorprone ' com.uber.nullaway:nullaway:0.12.6'
155+ errorprone ' com.google.errorprone:error_prone_core:2.37.0'
156+
157+ // just tests - no Kotlin otherwise
158+ testCompileOnly ' org.jetbrains.kotlin:kotlin-stdlib-jdk8'
135159}
136160
137161shadowJar {
@@ -218,6 +242,36 @@ compileJava {
218242 source file(" build/generated-src" ), sourceSets. main. java
219243}
220244
245+ tasks. withType(GroovyCompile ) {
246+ // Options when compiling Java using the Groovy plugin.
247+ // (Groovy itself defaults to UTF-8 for Groovy code)
248+ options. encoding = ' UTF-8'
249+ sourceCompatibility = ' 11'
250+ targetCompatibility = ' 11'
251+ groovyOptions. forkOptions. memoryMaximumSize = " 4g"
252+ }
253+
254+ tasks. withType(JavaCompile ) {
255+ options. release = 11
256+ options. errorprone {
257+ disableAllChecks = true
258+ check(" NullAway" , CheckSeverity . ERROR )
259+ //
260+ // end state has us with this config turned on - eg all classes
261+ //
262+ // option("NullAway:AnnotatedPackages", "graphql")
263+ option(" NullAway:CustomContractAnnotations" , " graphql.Contract" )
264+ option(" NullAway:OnlyNullMarked" , " true" )
265+ option(" NullAway:JSpecifyMode" , " true" )
266+ }
267+ // Include to disable NullAway on test code
268+ if (name. toLowerCase(). contains(" test" )) {
269+ options. errorprone {
270+ disable(" NullAway" )
271+ }
272+ }
273+ }
274+
221275generateGrammarSource {
222276 includes = [' Graphql.g4' ]
223277 maxHeapSize = " 64m"
@@ -253,6 +307,7 @@ artifacts {
253307List<TestDescriptor > failedTests = []
254308
255309test {
310+ useJUnitPlatform()
256311 testLogging {
257312 events " FAILED" , " SKIPPED"
258313 exceptionFormat = " FULL"
@@ -265,6 +320,43 @@ test {
265320 }
266321}
267322
323+ tasks. register(' testWithJava17' , Test ) {
324+ javaLauncher = javaToolchains. launcherFor {
325+ languageVersion = JavaLanguageVersion . of(17 )
326+ }
327+ useJUnitPlatform()
328+ testLogging {
329+ events " FAILED" , " SKIPPED"
330+ exceptionFormat = " FULL"
331+ }
332+
333+ afterTest { TestDescriptor descriptor , TestResult result ->
334+ if (result. getFailedTestCount() > 0 ) {
335+ failedTests. add(descriptor)
336+ }
337+ }
338+
339+ }
340+ tasks. register(' testWithJava11' , Test ) {
341+ javaLauncher = javaToolchains. launcherFor {
342+ languageVersion = JavaLanguageVersion . of(11 )
343+ }
344+ useJUnitPlatform()
345+ testLogging {
346+ events " FAILED" , " SKIPPED"
347+ exceptionFormat = " FULL"
348+ }
349+
350+ afterTest { TestDescriptor descriptor , TestResult result ->
351+ if (result. getFailedTestCount() > 0 ) {
352+ failedTests. add(descriptor)
353+ }
354+ }
355+ }
356+ test. dependsOn testWithJava17
357+ test. dependsOn testWithJava11
358+
359+
268360/*
269361 * The gradle.buildFinished callback is deprecated BUT there does not seem to be a decent alternative in gradle 7
270362 * So progress over perfection here
@@ -378,6 +470,5 @@ tasks.withType(GenerateModuleMetadata) {
378470 enabled = false
379471}
380472
381- test {
382- useJUnitPlatform()
383- }
473+
474+
0 commit comments