| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| 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' | ||
| Expand All | @@ -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', | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| Expand Down Expand Up | @@ -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' | ||
| Expand All | @@ -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 { | ||
| Expand Down Expand Up | @@ -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" | ||
| Expand Down Expand Up | @@ -253,6 +307,7 @@ artifacts { | |
| List<TestDescriptor> failedTests = [] | ||
|
|
||
| test { | ||
| useJUnitPlatform() | ||
| testLogging { | ||
| events "FAILED", "SKIPPED" | ||
| exceptionFormat = "FULL" | ||
| Expand All | @@ -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 | ||
|
|
||
|
Comment thread
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityNice - I am guessing this runs on both JDKs
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitywe specify inside the task different toolchains ...so we run the tests with different Java versions
Sorry, something went wrong.
All reactions
|
||
|
|
||
| /* | ||
| * The gradle.buildFinished callback is deprecated BUT there does not seem to be a decent alternative in gradle 7 | ||
| * So progress over perfection here | ||
| Expand Down Expand Up | @@ -374,6 +466,5 @@ tasks.withType(GenerateModuleMetadata) { | |
| enabled = false | ||
| } | ||
|
|
||
| test { | ||
| useJUnitPlatform() | ||
| } | ||
|
|
||
|
|
||
| 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 ""; | ||
|
|
||
| } |
| Back | FazBrowse Home | New Git URL |
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.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityWe should run gradle on the latest version by default.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.