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'
69 id ' java-library'
710 id ' maven-publish'
811 id ' antlr'
912 id ' signing'
10- id " com.gradleup.shadow" version " 8.3.6 "
13+ id " com.gradleup.shadow" version " 8.3.7 "
1114 id " biz.aQute.bnd.builder" version " 6.4.0"
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.3.0'
19+ //
20+ // Kotlin just for tests - not production code
21+ id ' org.jetbrains.kotlin.jvm' version ' 2.2.0'
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
@@ -64,7 +84,7 @@ def getDevelopmentVersion() {
6484
6585def reactiveStreamsVersion = ' 1.0.3'
6686def releaseVersion = System . env. RELEASE_VERSION
67- def antlrVersion = ' 4.11.1 ' // https://mvnrepository.com/artifact/org.antlr/antlr4-runtime
87+ def antlrVersion = ' 4.13.2 ' // https://mvnrepository.com/artifact/org.antlr/antlr4-runtime
6888def guavaVersion = ' 32.1.2-jre'
6989version = releaseVersion ? releaseVersion : getDevelopmentVersion()
7090group = ' com.graphql-java'
@@ -97,41 +117,45 @@ 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
108- api ' com.graphql-java:java-dataloader:4.0.0'
122+ 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'
115- testImplementation ' net.bytebuddy:byte-buddy:1.17.5 '
131+ testImplementation ' net.bytebuddy:byte-buddy:1.17.6 '
116132 testImplementation ' org.objenesis:objenesis:3.4'
117- testImplementation ' org.apache.groovy:groovy:4.0.26 "'
118- testImplementation ' org.apache.groovy:groovy-json:4.0.26 '
133+ testImplementation ' org.apache.groovy:groovy:4.0.27 "'
134+ testImplementation ' org.apache.groovy:groovy-json:4.0.27 '
119135 testImplementation ' com.google.code.gson:gson:2.13.1'
120136 testImplementation ' org.eclipse.jetty:jetty-server:11.0.25'
121- testImplementation ' com.fasterxml.jackson.core:jackson-databind:2.19.0 '
137+ testImplementation ' com.fasterxml.jackson.core:jackson-databind:2.19.1 '
122138 testImplementation ' org.awaitility:awaitility-groovy:4.3.0'
123139 testImplementation ' com.github.javafaker:javafaker:1.0.2'
124140
125141 testImplementation ' org.reactivestreams:reactive-streams-tck:' + reactiveStreamsVersion
126142 testImplementation " io.reactivex.rxjava2:rxjava:2.2.21"
127- testImplementation " io.projectreactor:reactor-core:3.7.5 "
143+ testImplementation " io.projectreactor:reactor-core:3.7.7 "
128144
129145 testImplementation ' org.testng:testng:7.11.0' // use for reactive streams test inheritance
130- testImplementation " com.tngtech.archunit:archunit-junit5:1.4.0"
146+ testImplementation " com.tngtech.archunit:archunit-junit5:1.4.1"
147+
148+ antlr ' org.antlr:antlr4:' + antlrVersion
131149
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.7'
155+ errorprone ' com.google.errorprone:error_prone_core:2.39.0'
156+
157+ // just tests - no Kotlin otherwise
158+ testCompileOnly ' org.jetbrains.kotlin:kotlin-stdlib-jdk8'
135159}
136160
137161shadowJar {
@@ -176,7 +200,7 @@ shadowJar {
176200 bnd('''
177201-exportcontents: graphql.*
178202-removeheaders: Private-Package
179- Import-Package: !android.os.*,!com.google.*,!org.checkerframework.*,!javax.annotation.*,! graphql.com.google.*,!org.antlr.*,!graphql.org.antlr.*,!sun.misc.*,org.jspecify.* ;resolution:=optional,*
203+ Import-Package: !android.os.*,!com.google.*,!org.checkerframework.*,!graphql.com.google.*,!org.antlr.*,!graphql.org.antlr.*,!sun.misc.*,org.jspecify.annotations ;resolution:=optional,*
180204''' )
181205}
182206
@@ -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
@@ -350,8 +442,12 @@ publishing {
350442nexusPublishing {
351443 repositories {
352444 sonatype {
353- username = System . env. MAVEN_CENTRAL_USER
354- password = System . env. MAVEN_CENTRAL_PASSWORD
445+ username = System . env. MAVEN_CENTRAL_USER_NEW
446+ password = System . env. MAVEN_CENTRAL_PASSWORD_NEW
447+ // https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration
448+ nexusUrl. set(uri(" https://ossrh-staging-api.central.sonatype.com/service/local/" ))
449+ // GraphQL Java does not publish snapshots, but adding this URL for completeness
450+ snapshotRepositoryUrl. set(uri(" https://central.sonatype.com/repository/maven-snapshots/" ))
355451 }
356452 }
357453}
@@ -374,6 +470,5 @@ tasks.withType(GenerateModuleMetadata) {
374470 enabled = false
375471}
376472
377- test {
378- useJUnitPlatform()
379- }
473+
474+
0 commit comments