diff --git a/build.gradle b/build.gradle index 0977eeeb1a..d69b06efb6 100644 --- a/build.gradle +++ b/build.gradle @@ -12,7 +12,7 @@ plugins { id 'antlr' id 'signing' id "com.gradleup.shadow" version "9.0.0" - id "biz.aQute.bnd.builder" version "6.4.0" + id "biz.aQute.bnd.builder" version "7.1.0" id "io.github.gradle-nexus.publish-plugin" version "2.0.0" id "groovy" id "me.champeau.jmh" version "0.7.3" @@ -127,7 +127,7 @@ dependencies { implementation 'org.antlr:antlr4-runtime:' + antlrVersion implementation 'com.google.guava:guava:' + guavaVersion - testImplementation group: 'junit', name: 'junit', version: '4.13.2' + testImplementation 'junit:junit:4.13.2' testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' testImplementation 'net.bytebuddy:byte-buddy:1.17.8' testImplementation 'org.objenesis:objenesis:3.4' @@ -146,6 +146,9 @@ dependencies { testImplementation 'org.testng:testng:7.11.0' // use for reactive streams test inheritance testImplementation "com.tngtech.archunit:archunit-junit5:1.4.1" testImplementation 'org.openjdk.jmh:jmh-core:1.37' // required for ArchUnit to check JMH tests + + // JUnit Platform launcher required for Gradle 9 + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' antlr 'org.antlr:antlr4:' + antlrVersion @@ -163,6 +166,8 @@ dependencies { testImplementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' } +import aQute.bnd.gradle.BundleTaskExtension + shadowJar { minimize() archiveClassifier.set('') @@ -186,27 +191,28 @@ shadowJar { manifest { attributes('Automatic-Module-Name': 'com.graphqljava') } - //Apply biz.aQute.bnd.builder plugin logic to shadowJar as in BndBuilderPlugin - convention.plugins.bundle = new aQute.bnd.gradle.BundleTaskConvention(it) - doLast { - //Call bnd after the ShadowJar was built to update the MANIFEST.MF - buildBundle() - } +} - //Configure bnd for shadowJar - // -exportcontents: graphql.* Adds all packages of graphql and below to the exported packages list - // -removeheaders: Private-Package Removes the MANIFEST.MF header Private-Package, which contains all the internal packages and - // also the repackaged packages like guava, which would be wrong after repackaging. - // Import-Package: Changes the imported packages header, to exclude guava and dependencies from the import list (! excludes packages) - // Guava was repackaged and included inside the jar, so we need to remove it. - // ANTLR was shaded, so we need to remove it. - // sun.misc is a JRE internal-only class that is not directly used by graphql-java. It was causing problems in libraries using graphql-java. - // The last ,* copies all the existing imports from the other dependencies, which is required. - bnd(''' +// Apply bnd to shadowJar task manually for Gradle 9 compatibility +tasks.named('shadowJar').configure { + // Get the BundleTaskExtension added by bnd plugin + def bundle = extensions.findByType(BundleTaskExtension) + if (bundle != null) { + //Configure bnd for shadowJar + // -exportcontents: graphql.* Adds all packages of graphql and below to the exported packages list + // -removeheaders: Private-Package Removes the MANIFEST.MF header Private-Package, which contains all the internal packages and + // also the repackaged packages like guava, which would be wrong after repackaging. + // Import-Package: Changes the imported packages header, to exclude guava and dependencies from the import list (! excludes packages) + // Guava was repackaged and included inside the jar, so we need to remove it. + // ANTLR was shaded, so we need to remove it. + // sun.misc is a JRE internal-only class that is not directly used by graphql-java. It was causing problems in libraries using graphql-java. + // The last ,* copies all the existing imports from the other dependencies, which is required. + bundle.bnd(''' -exportcontents: graphql.* -removeheaders: Private-Package Import-Package: !android.os.*,!com.google.*,!org.checkerframework.*,!graphql.com.google.*,!org.antlr.*,!graphql.org.antlr.*,!sun.misc.*,org.jspecify.annotations;resolution:=optional,* ''') + } } tasks.named('jmhJar') { @@ -235,9 +241,10 @@ task buildNewJar(type: Jar) { manifest { from file("build/extract/META-INF/MANIFEST.MF") } + def projectVersion = version doLast { - delete("build/libs/graphql-java-${project.version}.jar") - file("build/libs/graphql-java-tmp.jar").renameTo(file("build/libs/graphql-java-${project.version}.jar")) + delete("build/libs/graphql-java-${projectVersion}.jar") + file("build/libs/graphql-java-tmp.jar").renameTo(file("build/libs/graphql-java-${projectVersion}.jar")) } } @@ -254,6 +261,8 @@ check.dependsOn testng compileJava { options.compilerArgs += ["-parameters"] source file("build/generated-src"), sourceSets.main.java + // Gradle 9 requires explicit task dependencies + mustRunAfter generateTestGrammarSource, generateJmhGrammarSource } tasks.withType(GroovyCompile) { @@ -313,10 +322,7 @@ javadoc { options.encoding = 'UTF-8' } -artifacts { - archives sourcesJar - archives javadocJar -} +// Removed deprecated archives configuration in favor of direct assemble dependencies List failedTests = [] Map testsAndTime = [:] @@ -423,7 +429,7 @@ publishing { publications { graphqlJava(MavenPublication) { - version version + version = version from components.java artifact sourcesJar { @@ -488,7 +494,7 @@ nexusPublishing { } signing { - required { !project.hasProperty('publishToMavenLocal') } + setRequired { !project.hasProperty('publishToMavenLocal') } def signingKey = System.env.MAVEN_CENTRAL_PGP_KEY useInMemoryPgpKeys(signingKey, "") sign publishing.publications diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 9bbc975c74..f8e1ee3125 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 37f853b1c8..bad7c2462f 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.13-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index faf93008b7..adff685a03 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. @@ -114,7 +114,6 @@ case "$( uname )" in #( NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # 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,8 +210,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ "$@" # Stop when "xargs" is not available. diff --git a/gradlew.bat b/gradlew.bat index 9b42019c79..e509b2dd8f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -70,11 +70,10 @@ goto fail :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* +"%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 diff --git a/settings.gradle b/settings.gradle index b4870c3fc3..62e3428491 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,7 +2,7 @@ pluginManagement { repositories { mavenCentral() maven { - url 'https://plugins.gradle.org/m2' + url = 'https://plugins.gradle.org/m2' metadataSources { // Avoid redirection to defunct JCenter when Gradle module metadata is not published by a plugin (e.g. JMH plugin) ignoreGradleMetadataRedirection()