diff --git a/build.gradle b/build.gradle index f59e2ab4843f..2c206037fb9a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,7 @@ import de.undercouch.gradle.tasks.download.Download +import org.gradle.api.tasks.testing.TestDescriptor +import org.gradle.api.tasks.testing.TestListener +import org.gradle.api.tasks.testing.TestResult plugins { // https://plugins.gradle.org/plugin/com.gradleup.shadow @@ -88,7 +91,7 @@ ext { // * Uncomment "-Werror" errorprone : '2.48.0', // NOTE: Google Java Format requires JDK 17 or higher as of version 1.25.0. - googleJavaFormat : '1.25.2', + googleJavaFormat : '1.35.0', hashmapUtil : '0.0.1', junit : '4.13.2', lombok : '1.18.44', @@ -146,7 +149,7 @@ spotless { // > Could not create task ':checker-qual:spotlessJava'. // > File signature can only be created for existing regular files, given: // .../checker-framework/checker-qual/build/libs/checker-qual-3.25.1-SNAPSHOT.jar - predeclareDepsFromBuildscript() + predeclareDeps() } spotlessPredeclare { @@ -207,11 +210,11 @@ allprojects { currentProj -> dependencies { if (useJdkVersionInt >= 21) { // Only include Error Prone when its minimum version is met. It will not always be enabled. - errorprone group: 'com.google.errorprone', name: 'error_prone_core', version: versions.errorprone + errorprone("com.google.errorprone:error_prone_core:${versions.errorprone}") } // Always define javacJar, not just when `isJava8` is true, because we redistribute it in checker/build.gradle. - javacJar group: 'com.google.errorprone', name: 'javac', version: "9+181-r4173-1" + javacJar("com.google.errorprone:javac:9+181-r4173-1") allProjects subprojects } @@ -1212,18 +1215,25 @@ subprojects { } // After each test, print a summary. - afterSuite { desc, result -> - if (desc.getClassName() != null) { - long mils = result.getEndTime() - result.getStartTime() - double seconds = mils / 1000.0 - - println "Testsuite: ${desc.getClassName()}\n" + - "Tests run: ${result.testCount}, " + - "Failures: ${result.failedTestCount}, " + - "Skipped: ${result.skippedTestCount}, " + - "Time elapsed: ${seconds} sec\n" - } - } + addTestListener(new TestListener() { + @Override void beforeSuite(TestDescriptor suite) {} + @Override void beforeTest(TestDescriptor test) {} + @Override void afterTest(TestDescriptor test, TestResult result) {} + + @Override + void afterSuite(TestDescriptor desc, TestResult result) { + if (desc.getClassName() != null) { + long mils = result.getEndTime() - result.getStartTime() + double seconds = mils / 1000.0 + + println "Testsuite: ${desc.getClassName()}\n" + + "Tests run: ${result.testCount}, " + + "Failures: ${result.failedTestCount}, " + + "Skipped: ${result.skippedTestCount}, " + + "Time elapsed: ${seconds} sec\n" + } + } + }) } // Create a nonJunitTests task per project diff --git a/checker-qual/build.gradle b/checker-qual/build.gradle index 62ca3c7fbbc9..bc63cf7a9869 100644 --- a/checker-qual/build.gradle +++ b/checker-qual/build.gradle @@ -18,6 +18,19 @@ sourceSets { } } +jar { + doLast { + copy { + from archiveFile + into layout.projectDirectory.file('../checker/dist') + rename { String fileName -> + // remove version number on checker-qual.jar + fileName.replace(fileName, 'checker-qual.jar') + } + } + } +} + task compileJava9(type: JavaCompile) { source = sourceSets.module_info.java destinationDirectory = sourceSets.main.output.classesDirs[0] diff --git a/checker-util/build.gradle b/checker-util/build.gradle index 693edfd979f0..5bc20cc61296 100644 --- a/checker-util/build.gradle +++ b/checker-util/build.gradle @@ -9,6 +9,19 @@ dependencies { testImplementation "junit:junit:${versions.junit}" } +jar { + doLast { + copy { + from archiveFile + into layout.projectDirectory.file('../checker/dist') + rename { String fileName -> + // remove version number on checker-util.jar + fileName.replace(fileName, 'checker-util.jar') + } + } + } +} + apply from: rootProject.file('gradle-mvn-push.gradle') /** Adds information to the publication for uploading to Maven repositories. */ diff --git a/checker/build.gradle b/checker/build.gradle index 0d6ddc8d42f6..f8118119c00e 100644 --- a/checker/build.gradle +++ b/checker/build.gradle @@ -38,6 +38,7 @@ configurations { canBeConsumed = true canBeResolved = false } + checkerQual } dependencies { @@ -103,6 +104,7 @@ dependencies { testImplementation sourceSets.testannotations.output testannotationsImplementation project(':checker-qual') + checkerQual project(':checker-qual') } // Enable exec/javaexec @@ -136,34 +138,9 @@ jar { task assembleForJavac(dependsOn: shadowJar, group: 'Build') { description = 'Builds or downloads jars required by CheckerMain and puts them in checker/dist/.' dependsOn project(':checker-qual').tasks.jar - def checkerQualJarFile = file(project(':checker-qual').tasks.getByName('jar').archiveFile) - def checkerUtilJarFile = file(project(':checker-util').tasks.getByName('jar').archiveFile) + dependsOn project(':checker-util').tasks.jar doLast { - if (!checkerQualJarFile.exists()) { - throw new GradleException('File not found: ' + checkerQualJarFile) - } - copy { - from checkerQualJarFile - into "${projectDir}/dist" - rename { String fileName -> - // remove version number on checker-qual.jar - fileName.replace(fileName, 'checker-qual.jar') - } - } - - if (!checkerUtilJarFile.exists()) { - throw new GradleException('File not found: ' + checkerUtilJarFile) - } - copy { - from checkerUtilJarFile - into "${projectDir}/dist" - rename { String fileName -> - // remove version number on checker-util.jar - fileName.replace(fileName, 'checker-util.jar') - } - } - copy { // This is required to *run* the Checker Framework on JDK 8. from configurations.javacJar @@ -242,16 +219,21 @@ shadowJar { } } - minimize() + minimize { + exclude(dependency('org.checkerframework:checker-qual:.*')) + exclude(dependency('org.checkerframework:checker-util:.*')) + } } -artifacts { +tasks.named("assemble") { // Don't add this here or else the Javadoc and the sources jar is built during the assemble task. // archives allJavadocJar // archives allSourcesJar - archives shadowJar - archives checkerJar + dependsOn(shadowJar) + dependsOn(checkerJar) +} +artifacts { fatJar(shadowJar) } @@ -384,7 +366,7 @@ task jtregJdk11Tests(type: Exec, group: 'Verification') { dependsOn('compileTestJava') dependsOn('shadowJar') - String jtregOutput = "${buildDir}/jtregJdk11" + String jtregOutput = "${layout.buildDir}/jtregJdk11" String name = 'all' executable "${jtregHome}/bin/jtreg" @@ -463,11 +445,14 @@ test { task ainferTestCheckerGenerateStubs(type: Test) { description = 'Internal task. Users should run ainferTestCheckerStubTest instead. This type-checks the ainfer-testchecker files with -Ainfer=stubs to generate stub files.' - dependsOn(compileTestJava) + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + doFirst { delete('tests/ainfer-testchecker/annotated') - delete("${buildDir}/ainfer-testchecker/") + delete("${layout.buildDir}/ainfer-testchecker/") } outputs.upToDateWhen { false } include '**/AinferTestCheckerStubsGenerationTest.class' @@ -506,8 +491,11 @@ task ainferTestCheckerGenerateStubs(type: Test) { task ainferTestCheckerValidateStubs(type: Test) { description = 'Internal task. Users should run ainferTestCheckerStubTest instead. This type-checks the ainfer-testchecker tests using the stub files generated by ainferTestCheckerGenerateStubs.' - dependsOn(ainferTestCheckerGenerateStubs) + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + outputs.upToDateWhen { false } include '**/AinferTestCheckerStubsValidationTest.class' testLogging { @@ -522,11 +510,14 @@ task ainferTestCheckerValidateStubs(type: Test) { task ainferTestCheckerGenerateAjava(type: Test) { description = 'Internal task. Users should run ainferTestCheckerAjavaTest instead. This type-checks the ainfer-testchecker files with -Ainfer=ajava to generate ajava files.' - dependsOn(compileTestJava) + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + doFirst { delete('tests/ainfer-testchecker/annotated') - delete("${buildDir}/ainfer-testchecker/") + delete("${layout.buildDir}/ainfer-testchecker/") } outputs.upToDateWhen { false } include '**/AinferTestCheckerAjavaGenerationTest.class' @@ -565,8 +556,11 @@ task ainferTestCheckerGenerateAjava(type: Test) { task ainferTestCheckerValidateAjava(type: Test) { description = 'Internal task. Users should run ainferTestCheckerAjavaTest instead. This re-type-checks the ainfer-testchecker files using the ajava files generated by ainferTestCheckerGenerateAjava' - dependsOn(ainferTestCheckerGenerateAjava) + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + outputs.upToDateWhen { false } include '**/AinferTestCheckerAjavaValidationTest.class' testLogging { @@ -630,6 +624,8 @@ task ainferTestCheckerGenerateJaifs(type: Test) { dependsOn(compileTestJava) dependsOn(':checker-qual:jar') // For the Value Checker annotations. + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath doFirst { delete('tests/ainfer-testchecker/annotated') } @@ -675,14 +671,16 @@ tasks.register('ainferTestCheckerGenerateJaifsInsertAnnotations', InsertAnnotati afuDir = afu testDir = 'tests/ainfer-testchecker' - def checkerQualJarFile = file(project(':checker-qual').tasks.getByName('jar').archiveFile) - classpath = "${sourceSets.test.output.asPath}:${checkerQualJarFile}:" + classpath = "${sourceSets.test.output.asPath}:${configurations.checkerQual.singleFile}:" } task ainferTestCheckerValidateJaifs(type: Test) { description = 'Internal task. Users should run ainferTestCheckerJaifTest instead. This type-checks the ainfer-testchecker files using the .jaif files generated by ainferTestCheckerGenerateJaifs' - dependsOn(ainferTestCheckerGenerateJaifs) + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + outputs.upToDateWhen { false } include '**/AinferTestCheckerJaifsValidationTest.class' testLogging { @@ -703,11 +701,12 @@ task ainferTestCheckerJaifTest(dependsOn: 'shadowJar', group: 'Verification') { task ainferIndexGenerateAjava(type: Test) { description = 'Internal task. Users should run ainferIndexAjavaTest instead. This type-checks the ainfer-index files with -Ainfer=ajava to generate ajava files.' - dependsOn(compileTestJava) + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath doFirst { delete('tests/ainfer-index/annotated') - delete("${buildDir}/ainfer-index/") + delete("${layout.buildDir}/ainfer-index/") } outputs.upToDateWhen { false } include '**/AinferIndexAjavaGenerationTest.class' @@ -727,8 +726,10 @@ task ainferIndexGenerateAjava(type: Test) { task ainferIndexValidateAjava(type: Test) { description = 'Internal task. Users should run ainferIndexAjavaTest instead. This re-type-checks the ainfer-index files using the ajava files generated by ainferIndexGenerateAjava' - dependsOn(ainferIndexGenerateAjava) + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath outputs.upToDateWhen { false } include '**/AinferIndexAjavaValidationTest.class' testLogging { @@ -749,11 +750,14 @@ task ainferIndexAjavaTest(dependsOn: 'shadowJar', group: 'Verification') { task ainferNullnessGenerateAjava(type: Test) { description = 'Internal task. Users should run ainferNullnessAjavaTest instead. This type-checks the ainfer-nullness files with -Ainfer=ajava to generate ajava files.' - dependsOn(compileTestJava) + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + doFirst { delete('tests/ainfer-nullness/annotated') - delete("${buildDir}/ainfer-nullness/") + delete("${layout.buildDir}/ainfer-nullness/") } outputs.upToDateWhen { false } include '**/AinferNullnessAjavaGenerationTest.class' @@ -773,8 +777,11 @@ task ainferNullnessGenerateAjava(type: Test) { task ainferNullnessValidateAjava(type: Test) { description = 'Internal task. Users should run ainferNullnessAjavaTest instead. This re-type-checks the ainfer-nullness files using the ajava files generated by ainferNullnessGenerateAjava' - dependsOn(ainferNullnessGenerateAjava) + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + outputs.upToDateWhen { false } include '**/AinferNullnessAjavaValidationTest.class' testLogging { @@ -795,11 +802,14 @@ task ainferNullnessAjavaTest(dependsOn: 'shadowJar', group: 'Verification') { task ainferResourceLeakGenerateAjava(type: Test) { description = 'Internal task. Users should run ainferResourceLeakAjavaTest instead. This type-checks the ainfer-index files with -Ainfer=ajava to generate ajava files.' - dependsOn(compileTestJava) + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + doFirst { delete('tests/ainfer-resourceleak/annotated') - delete("${buildDir}/ainfer-resourceleak/") + delete("${layout.buildDir}/ainfer-resourceleak/") } outputs.upToDateWhen { false } include '**/AinferResourceLeakAjavaGenerationTest.class' @@ -819,8 +829,11 @@ task ainferResourceLeakGenerateAjava(type: Test) { task ainferResourceLeakValidateAjava(type: Test) { description = 'Internal task. Users should run ainferResourceLeakAjavaTest instead. This re-type-checks the ainfer-resourceleak files using the ajava files generated by ainferResourceLeakGenerateAjava' - dependsOn(ainferResourceLeakGenerateAjava) + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + outputs.upToDateWhen { false } include '**/AinferResourceLeakAjavaValidationTest.class' testLogging { @@ -841,8 +854,11 @@ task ainferResourceLeakAjavaTest(dependsOn: 'shadowJar', group: 'Verification') task ainferNullnessGenerateJaifs(type: Test) { description = 'Internal task. Users should run ainferNullnessJaifTest instead. This type-checks the ainfer-nullness files with -Ainfer=jaifs to generate .jaif files' - dependsOn(compileTestJava) + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + doFirst { delete('tests/ainfer-nullness/annotated') } @@ -857,30 +873,25 @@ task ainferNullnessGenerateJaifs(type: Test) { events 'passed', 'skipped', 'failed' } - def injected = project.objects.newInstance(InjectedExecOps) - - doLast { - copyNonannotatedToAnnotatedDirectory('ainfer-nullness') - - // JAIF-based WPI does not infer annotations on uses of type variables correctly. - delete('tests/ainfer-nullness/annotated/TwoCtorGenericAbstract.java') - delete('tests/ainfer-nullness/annotated/TypeVarReturnAnnotated.java') - } - finalizedBy 'ainferNullnessGenerateJaifsInsertAnnotations' + // JAIF-based WPI does not infer annotations on uses of type variables correctly. + delete('tests/ainfer-nullness/annotated/TwoCtorGenericAbstract.java') + delete('tests/ainfer-nullness/annotated/TypeVarReturnAnnotated.java') } tasks.register('ainferNullnessGenerateJaifsInsertAnnotations', InsertAnnotationsToSource) { dependsOn ainferNullnessGenerateJaifs afuDir = afu testDir = 'tests/ainfer-nullness/' - def checkerQualJarFile = file(project(':checker-qual').tasks.getByName('jar').archiveFile) - classpath = "${sourceSets.test.output.asPath}:${checkerQualJarFile}:" + classpath = "${sourceSets.test.output.asPath}:${configurations.checkerQual.singleFile}:" } task ainferNullnessValidateJaifs(type: Test) { description = 'Internal task. Users should run ainferNullnessJaifTest instead. This re-type-checks the ainfer-nullness files using the .jaif files generated by ainferNullnessGenerateJaifs' + dependsOn('ainferNullnessGenerateJaifsInsertAnnotations') + + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath - dependsOn(ainferNullnessGenerateJaifs) outputs.upToDateWhen { false } include '**/AinferNullnessJaifsValidationTest.class' testLogging { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 1b33c55baabb..d997cfc60f4c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aaaabb3cb9fe..c61a118f7ddb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.4-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index 23d15a936707..739907dfd159 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -114,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH="\\\"\\\"" # Determine the Java command to use to start the JVM. @@ -172,7 +171,6 @@ fi # For Cygwin or MSYS, switch paths to Windows format before running java if "$cygwin" || "$msys" ; then APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) JAVACMD=$( cygpath --unix "$JAVACMD" ) @@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" diff --git a/gradlew.bat b/gradlew.bat index db3a6ac207e5..c4bdd3ab8e3c 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -70,11 +70,10 @@ goto fail :execute @rem Setup the command line -set CLASSPATH= @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* :end @rem End local scope for the variables with windows NT shell