-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Adding errorprone support and fix chained dataloader bug #4002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2ecbd70
Adding errorprone support
bbakerman 6439f97
Update build.gradle
andimarek 0827877
nullable types
andimarek a66d8b3
Merge branch 'master' into errorprone-jspecify-nullaway-support
andimarek 13f89aa
nullable types
andimarek 94efefc
fix tests
andimarek d9de9b4
add custom contract annotation
andimarek 6fcc767
make test fail faster
andimarek 971f2e4
groovy compatibility
andimarek 1d5d4f6
fix concurrent problem in dispatching strategy
andimarek f2bf6f3
run tests on 11 and 17 too
andimarek 0cece8d
use java 21 to run gradle
andimarek 29c2c37
tests reporting
andimarek 4b5751e
error reporting
andimarek d46e247
error reporting
andimarek a05a319
Ignore test when run on Java version > 11
andimarek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| import java.text.SimpleDateFormat | ||
| import net.ltgt.gradle.errorprone.CheckSeverity | ||
| import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
| import org.jetbrains.kotlin.gradle.dsl.KotlinVersion | ||
|
|
||
| import java.text.SimpleDateFormat | ||
|
|
||
| plugins { | ||
| id 'java' | ||
|
|
@@ -12,11 +15,28 @@ plugins { | |
| id "io.github.gradle-nexus.publish-plugin" version "2.0.0" | ||
| id "groovy" | ||
| id "me.champeau.jmh" version "0.7.3" | ||
| id "net.ltgt.errorprone" version '4.2.0' | ||
| // | ||
| // Kotlin just for tests - not production code | ||
| id 'org.jetbrains.kotlin.jvm' version '2.1.21' | ||
| } | ||
|
|
||
| java { | ||
| toolchain { | ||
| languageVersion = JavaLanguageVersion.of(11) | ||
| languageVersion = JavaLanguageVersion.of(21) // build on 21 - release on 11 | ||
| } | ||
| } | ||
|
|
||
| kotlin { | ||
| compilerOptions { | ||
| apiVersion = KotlinVersion.KOTLIN_2_0 | ||
| languageVersion = KotlinVersion.KOTLIN_2_0 | ||
| jvmTarget = JvmTarget.JVM_11 | ||
| javaParameters = true | ||
| freeCompilerArgs = [ | ||
| '-Xemit-jvm-type-annotations', | ||
| '-Xjspecify-annotations=strict', | ||
| ] | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -97,19 +117,15 @@ jar { | |
| attributes('Automatic-Module-Name': 'com.graphqljava') | ||
| } | ||
| } | ||
| tasks.withType(GroovyCompile) { | ||
| // Options when compiling Java using the Groovy plugin. | ||
| // (Groovy itself defaults to UTF-8 for Groovy code) | ||
| options.encoding = 'UTF-8' | ||
| groovyOptions.forkOptions.memoryMaximumSize = "4g" | ||
| } | ||
|
|
||
| dependencies { | ||
| implementation 'org.antlr:antlr4-runtime:' + antlrVersion | ||
| api 'com.graphql-java:java-dataloader:5.0.0' | ||
| api 'org.reactivestreams:reactive-streams:' + reactiveStreamsVersion | ||
| api "org.jspecify:jspecify:1.0.0" | ||
| antlr 'org.antlr:antlr4:' + antlrVersion | ||
|
|
||
| implementation 'org.antlr:antlr4-runtime:' + antlrVersion | ||
| implementation 'com.google.guava:guava:' + guavaVersion | ||
|
|
||
| testImplementation group: 'junit', name: 'junit', version: '4.13.2' | ||
| testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' | ||
| testImplementation 'net.bytebuddy:byte-buddy:1.17.5' | ||
|
|
@@ -129,9 +145,17 @@ dependencies { | |
| testImplementation 'org.testng:testng:7.11.0' // use for reactive streams test inheritance | ||
| testImplementation "com.tngtech.archunit:archunit-junit5:1.4.1" | ||
|
|
||
| antlr 'org.antlr:antlr4:' + antlrVersion | ||
|
|
||
| // this is needed for the idea jmh plugin to work correctly | ||
| jmh 'org.openjdk.jmh:jmh-core:1.37' | ||
| jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.37' | ||
|
|
||
| errorprone 'com.uber.nullaway:nullaway:0.12.6' | ||
| errorprone 'com.google.errorprone:error_prone_core:2.37.0' | ||
|
|
||
| // just tests - no Kotlin otherwise | ||
| testCompileOnly 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' | ||
| } | ||
|
|
||
| shadowJar { | ||
|
|
@@ -218,6 +242,36 @@ compileJava { | |
| source file("build/generated-src"), sourceSets.main.java | ||
| } | ||
|
|
||
| tasks.withType(GroovyCompile) { | ||
| // Options when compiling Java using the Groovy plugin. | ||
| // (Groovy itself defaults to UTF-8 for Groovy code) | ||
| options.encoding = 'UTF-8' | ||
| sourceCompatibility = '11' | ||
| targetCompatibility = '11' | ||
| groovyOptions.forkOptions.memoryMaximumSize = "4g" | ||
| } | ||
|
|
||
| tasks.withType(JavaCompile) { | ||
| options.release = 11 | ||
| options.errorprone { | ||
| disableAllChecks = true | ||
| check("NullAway", CheckSeverity.ERROR) | ||
| // | ||
| // end state has us with this config turned on - eg all classes | ||
| // | ||
| //option("NullAway:AnnotatedPackages", "graphql") | ||
| option("NullAway:CustomContractAnnotations", "graphql.Contract") | ||
| option("NullAway:OnlyNullMarked", "true") | ||
| option("NullAway:JSpecifyMode", "true") | ||
| } | ||
| // Include to disable NullAway on test code | ||
| if (name.toLowerCase().contains("test")) { | ||
| options.errorprone { | ||
| disable("NullAway") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| generateGrammarSource { | ||
| includes = ['Graphql.g4'] | ||
| maxHeapSize = "64m" | ||
|
|
@@ -253,6 +307,7 @@ artifacts { | |
| List<TestDescriptor> failedTests = [] | ||
|
|
||
| test { | ||
| useJUnitPlatform() | ||
| testLogging { | ||
| events "FAILED", "SKIPPED" | ||
| exceptionFormat = "FULL" | ||
|
|
@@ -265,6 +320,43 @@ test { | |
| } | ||
| } | ||
|
|
||
| tasks.register('testWithJava17', Test) { | ||
| javaLauncher = javaToolchains.launcherFor { | ||
| languageVersion = JavaLanguageVersion.of(17) | ||
| } | ||
| useJUnitPlatform() | ||
| testLogging { | ||
| events "FAILED", "SKIPPED" | ||
| exceptionFormat = "FULL" | ||
| } | ||
|
|
||
| afterTest { TestDescriptor descriptor, TestResult result -> | ||
| if (result.getFailedTestCount() > 0) { | ||
| failedTests.add(descriptor) | ||
| } | ||
| } | ||
|
|
||
| } | ||
| tasks.register('testWithJava11', Test) { | ||
| javaLauncher = javaToolchains.launcherFor { | ||
| languageVersion = JavaLanguageVersion.of(11) | ||
| } | ||
| useJUnitPlatform() | ||
| testLogging { | ||
| events "FAILED", "SKIPPED" | ||
| exceptionFormat = "FULL" | ||
| } | ||
|
|
||
| afterTest { TestDescriptor descriptor, TestResult result -> | ||
| if (result.getFailedTestCount() > 0) { | ||
| failedTests.add(descriptor) | ||
| } | ||
| } | ||
| } | ||
| test.dependsOn testWithJava17 | ||
| test.dependsOn testWithJava11 | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice - I am guessing this runs on both JDKs
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we specify inside the task different toolchains ...so we run the tests with different Java versions |
||
|
|
||
| /* | ||
| * The gradle.buildFinished callback is deprecated BUT there does not seem to be a decent alternative in gradle 7 | ||
| * So progress over perfection here | ||
|
|
@@ -374,6 +466,5 @@ tasks.withType(GenerateModuleMetadata) { | |
| enabled = false | ||
| } | ||
|
|
||
| test { | ||
| useJUnitPlatform() | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package graphql; | ||
|
|
||
| import java.lang.annotation.Documented; | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Target; | ||
|
|
||
| /** | ||
| * Custom contract annotation used for jspecify and NullAway checks. | ||
| * | ||
| * This is the same as Spring does: we don't want any additional dependencies, therefore we define our own Contract annotation. | ||
| * | ||
| * @see <a href="https://raw.githubusercontent.com/spring-projects/spring-framework/refs/heads/main/spring-core/src/main/java/org/springframework/lang/Contract.java">Spring Framework Contract</a> | ||
| * @see <a href="https://github.com/JetBrains/java-annotations/blob/master/src/jvmMain/java/org/jetbrains/annotations/Contract.java">org.jetbrains.annotations.Contract</a> | ||
| * @see <a href="https://github.com/uber/NullAway/wiki/Configuration#custom-contract-annotations"> | ||
| * NullAway custom contract annotations</a> | ||
| */ | ||
| @Documented | ||
| @Target(ElementType.METHOD) | ||
| @Internal | ||
| public @interface Contract { | ||
|
|
||
| /** | ||
| * Describing the contract between call arguments and the returned value. | ||
| */ | ||
| String value() default ""; | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should run gradle on the latest version by default.