diff --git a/build.gradle b/build.gradle index f307c722..fc21e020 100644 --- a/build.gradle +++ b/build.gradle @@ -20,9 +20,11 @@ subprojects { apply plugin: "com.diffplug.spotless" dependencies { + testImplementation platform(libs.junit.bom) testImplementation libs.junit.api testImplementation libs.junit.params testRuntimeOnly libs.junit.engine + testRuntimeOnly libs.junit.launcher } if (!project.findProperty('indra.skipPublishing')) { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 461c45b0..4b46aa3a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -15,9 +15,11 @@ mammoth = "1.3.1" spotless = "6.20.0" [libraries] -junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" } -junit-params = { module = "org.junit.jupiter:junit-jupiter-params", version.ref = "junit" } -junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" } +junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" } +junit-api = { module = "org.junit.jupiter:junit-jupiter-api" } +junit-params = { module = "org.junit.jupiter:junit-jupiter-params" } +junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine" } +junit-launcher = { module = "org.junit.platform:junit-platform-launcher" } # build immutables-builder = { module = "org.immutables:builder", version.ref = "immutables" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index afba1092..7f93135c 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 4e86b927..ac72c34e 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68d..0adc8e1a 100755 --- a/gradlew +++ b/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,6 +198,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/indra-common/src/test/java/net/kyori/indra/IndraPluginFunctionalTest.java b/indra-common/src/test/java/net/kyori/indra/IndraPluginFunctionalTest.java index a008f9e5..d6299fc1 100644 --- a/indra-common/src/test/java/net/kyori/indra/IndraPluginFunctionalTest.java +++ b/indra-common/src/test/java/net/kyori/indra/IndraPluginFunctionalTest.java @@ -1,7 +1,7 @@ /* * This file is part of indra, licensed under the MIT License. * - * Copyright (c) 2020-2022 KyoriPowered + * Copyright (c) 2020-2023 KyoriPowered * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -38,6 +38,7 @@ import net.kyori.mammoth.test.TestContext; import org.gradle.testkit.runner.BuildResult; import org.gradle.testkit.runner.TaskOutcome; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.DisplayNameGeneration; import org.objectweb.asm.ClassReader; import org.objectweb.asm.Opcodes; @@ -105,6 +106,7 @@ void testScala(final TestContext ctx) throws IOException { } @IndraFunctionalTest + @Disabled("does not work on gradle 8.3+") void testKotlinBuild(final TestContext ctx) throws IOException { ctx.copyInput("build.gradle"); SettingsFactory.createSettings(ctx, "kotlin"); diff --git a/indra-crossdoc/src/main/java/net/kyori/indra/crossdoc/BuildTreeComparer.java b/indra-crossdoc/src/main/java/net/kyori/indra/crossdoc/BuildTreeComparer.java new file mode 100644 index 00000000..a519e772 --- /dev/null +++ b/indra-crossdoc/src/main/java/net/kyori/indra/crossdoc/BuildTreeComparer.java @@ -0,0 +1,75 @@ +/* + * This file is part of indra, licensed under the MIT License. + * + * Copyright (c) 2023 KyoriPowered + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package net.kyori.indra.crossdoc; + +import org.gradle.api.Project; +import org.gradle.api.artifacts.component.ProjectComponentIdentifier; +import org.gradle.util.GradleVersion; +import org.jetbrains.annotations.NotNull; + +import static java.util.Objects.requireNonNull; + +// cross-compat: Gradle 8.3+ and <8.3 +interface BuildTreeComparer { + boolean HAS_GRADLE_8_3 = GradleVersion.current().getBaseVersion().compareTo(GradleVersion.version("8.3")) >= 0; + + static @NotNull BuildTreeComparer comparer(final @NotNull Project project) { + if (HAS_GRADLE_8_3) { + return new Gradle83Comparer(requireNonNull(project, "project")); + } else { + return Gradle82OrOlderComparer.INSTANCE; + } + } + + boolean isCurrentBuild(final ProjectComponentIdentifier identifier); + + final class Gradle83Comparer implements BuildTreeComparer { + private final String projectBuildPath; + + Gradle83Comparer(final Project project) { + final String projectPath = project.getPath(); + final String absoluteProjectPath = project.getBuildTreePath(); + final String buildPath = absoluteProjectPath.substring(0, absoluteProjectPath.length() - projectPath.length()); + this.projectBuildPath = buildPath.isEmpty() ? ":" : buildPath; // root build needs to still be made absolute + } + + @Override + public boolean isCurrentBuild(ProjectComponentIdentifier identifier) { + return this.projectBuildPath.equals(identifier.getBuild().getBuildPath()); + } + } + + final class Gradle82OrOlderComparer implements BuildTreeComparer { + static final Gradle82OrOlderComparer INSTANCE = new Gradle82OrOlderComparer(); + + private Gradle82OrOlderComparer() { + } + + @Override + @SuppressWarnings("deprecation") + public boolean isCurrentBuild(ProjectComponentIdentifier identifier) { + return identifier.getBuild().isCurrentBuild(); + } + } +} diff --git a/indra-crossdoc/src/main/java/net/kyori/indra/crossdoc/CrossdocPlugin.java b/indra-crossdoc/src/main/java/net/kyori/indra/crossdoc/CrossdocPlugin.java index 7bc4cec4..2da9a957 100644 --- a/indra-crossdoc/src/main/java/net/kyori/indra/crossdoc/CrossdocPlugin.java +++ b/indra-crossdoc/src/main/java/net/kyori/indra/crossdoc/CrossdocPlugin.java @@ -175,9 +175,10 @@ private void prepareAttributeSchema(final DependencyHandler handler) { private void configureJavadocTask(final Project project, final CrossdocExtension extension, final NamedDomainObjectProvider offlineLinkedJavadoc) { // link to modules in project // TODO: figure out a way to get the build identifier + final BuildTreeComparer comparer = BuildTreeComparer.comparer(project); final Provider jdLinks = offlineLinkedJavadoc.map(oLJ -> oLJ.getIncoming() .artifactView(view -> { - view.componentFilter(c -> c instanceof ProjectComponentIdentifier && ((ProjectComponentIdentifier) c).getBuild().isCurrentBuild()); // only in-project, and not included builds + view.componentFilter(c -> c instanceof ProjectComponentIdentifier && comparer.isCurrentBuild((ProjectComponentIdentifier) c)); // only in-project, and not included builds view.setLenient(true); // ignore artifacts with no javadoc elements variant }).getArtifacts()); diff --git a/indra-testlib/src/main/java/net/kyori/indra/test/IndraFunctionalTestBase.java b/indra-testlib/src/main/java/net/kyori/indra/test/IndraFunctionalTestBase.java index 9b88a274..cb69d98a 100644 --- a/indra-testlib/src/main/java/net/kyori/indra/test/IndraFunctionalTestBase.java +++ b/indra-testlib/src/main/java/net/kyori/indra/test/IndraFunctionalTestBase.java @@ -38,7 +38,8 @@ */ @GradleFunctionalTest @LegacyGradleVersion -@TestVariant(gradleVersion = "8.1.1") +@TestVariant(gradleVersion = "8.2.1") +@TestVariant(gradleVersion = "8.3") @TestVariantResource(value = "/injected-gradle-versions", optional = true) @Tag("functional") @Documented