Skip to content

Commit

Permalink
chore(deps): Upgradle to 8.3
Browse files Browse the repository at this point in the history
Closes GH-118
  • Loading branch information
zml2008 committed Aug 27, 2023
1 parent b9e760c commit ddd411e
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 14 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
8 changes: 5 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
19 changes: 12 additions & 7 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -133,26 +131,29 @@ 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.
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
case $MAX_FD in #(
'' | 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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@ private void prepareAttributeSchema(final DependencyHandler handler) {
private void configureJavadocTask(final Project project, final CrossdocExtension extension, final NamedDomainObjectProvider<Configuration> offlineLinkedJavadoc) {
// link to modules in project
// TODO: figure out a way to get the build identifier
final BuildTreeComparer comparer = BuildTreeComparer.comparer(project);
final Provider<ArtifactCollection> 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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ddd411e

Please sign in to comment.