Skip to content

Commit

Permalink
Bump to gradle 8.4 (#3916)
Browse files Browse the repository at this point in the history
* Bump to gradle 8.4

* Bump to gradle 8.4

* chore(build): Massage deps output task

* Bump gradle wrapper

---------

Co-authored-by: zml <[email protected]>
  • Loading branch information
ImMorpheus and zml2008 authored Nov 12, 2023
1 parent d03fa69 commit 3f22b74
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 43 deletions.
2 changes: 1 addition & 1 deletion build-logic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ indra {

dependencies {
api("com.google.code.gson:gson:2.9.1")
implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.1.6")
implementation("gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.1.7")
}

indraSpotlessLicenser {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,16 @@
import org.gradle.api.DefaultTask;
import org.gradle.api.GradleException;
import org.gradle.api.NamedDomainObjectProvider;
import org.gradle.api.artifacts.ArtifactCollection;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.component.ComponentIdentifier;
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
import org.gradle.api.artifacts.result.ResolvedArtifactResult;
import org.gradle.api.file.RegularFileProperty;
import org.gradle.api.provider.MapProperty;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.SetProperty;
import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.Internal;
import org.gradle.api.tasks.Nested;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.OutputFile;
Expand Down Expand Up @@ -161,12 +160,15 @@ public final void dependencies(final String key, final NamedDomainObjectProvider
* Excludes configuration, to remove certain entries from dependencies and
* transitive dependencies of {@link #getDependencies()}.
*/
@Internal
public abstract SetProperty<ResolvedArtifactResult> getExcludedDependencies();

@Input
@Optional
public abstract Property<Configuration> getExcludedDependencies();
protected abstract SetProperty<ModuleComponentIdentifier> getExcludedDependenciesBuildInput();

public final void excludedDependencies(final NamedDomainObjectProvider<Configuration> config) {
this.getExcludedDependencies().set(config);
this.getExcludedDependencies().set(config.flatMap(conf -> conf.getIncoming().getArtifacts().getResolvedArtifacts()));
}

/**
Expand All @@ -180,13 +182,20 @@ public final void excludedDependencies(final NamedDomainObjectProvider<Configura

public OutputDependenciesToJson() {
this.getAllowedClassifiers().add("");
this.getExcludedDependenciesBuildInput().set(this.getExcludedDependencies().map(deps -> {
return deps.stream()
.map(res -> res.getId().getComponentIdentifier())
.filter(res -> res instanceof ModuleComponentIdentifier)
.map(res -> (ModuleComponentIdentifier) res)
.collect(Collectors.toSet());
}));
}

@TaskAction
public void generateDependenciesJson() {
final Set<ModuleComponentIdentifier> excludedDeps = new HashSet<>();
if (this.getExcludedDependencies().isPresent()) {
for (final ResolvedArtifactResult result : this.getExcludedDependencies().get().getIncoming().getArtifacts()) {
for (final ResolvedArtifactResult result : this.getExcludedDependencies().get()) {
if (result.getId().getComponentIdentifier() instanceof ModuleComponentIdentifier) {
excludedDeps.add((ModuleComponentIdentifier) result.getId().getComponentIdentifier());
}
Expand All @@ -197,7 +206,7 @@ public void generateDependenciesJson() {
final Map<String, List<DependencyDescriptor>> dependenciesMap = new TreeMap<>();

for (final Map.Entry<String, ConfigurationHolder> entry : inputConfigs.entrySet()) {
dependenciesMap.put(entry.getKey(), this.configToDescriptor(entry.getValue().getConfiguration().getIncoming().getArtifacts(), excludedDeps));
dependenciesMap.put(entry.getKey(), this.configToDescriptor(entry.getValue().getArtifacts().get(), excludedDeps));
}
final DependencyManifest manifest = new DependencyManifest(dependenciesMap);

Expand All @@ -212,8 +221,8 @@ public void generateDependenciesJson() {
}
}

private List<DependencyDescriptor> configToDescriptor(final ArtifactCollection conf, final Set<ModuleComponentIdentifier> excludedDeps) {
return conf.getArtifacts().stream()
private List<DependencyDescriptor> configToDescriptor(final Set<ResolvedArtifactResult> conf, final Set<ModuleComponentIdentifier> excludedDeps) {
return conf.stream()
.filter(dep -> {
final ComponentIdentifier ident = dep.getId().getComponentIdentifier();
return ident instanceof ModuleComponentIdentifier && !excludedDeps.contains(ident);
Expand Down Expand Up @@ -260,14 +269,23 @@ public static String toHexString(final byte[] bytes) {
}

public static class ConfigurationHolder {
private final Configuration configuration;
private final Provider<Set<ResolvedArtifactResult>> configuration;

public ConfigurationHolder(final Configuration configuration) {
this.configuration = configuration;
this.configuration = configuration.getIncoming().getArtifacts().getResolvedArtifacts();
}

@Input
public Provider<Set<ModuleComponentIdentifier>> getIds() {
return this.getArtifacts().map(set -> set.stream()
.map(art -> art.getId().getComponentIdentifier())
.filter(id -> id instanceof ModuleComponentIdentifier)
.map(art -> (ModuleComponentIdentifier) art)
.collect(Collectors.toSet()));
}

@InputFiles
public Configuration getConfiguration() {
@Internal
public Provider<Set<ResolvedArtifactResult>> getArtifacts() {
return this.configuration;
}
}
Expand Down
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ allprojects {
apply(plugin = "net.kyori.indra.licenser.spotless")

base {
archivesBaseName = name.toLowerCase(Locale.ENGLISH)
archivesName = name.lowercase(Locale.ENGLISH)
}

plugins.withId("org.spongepowered.gradle.vanilla") {
Expand Down Expand Up @@ -350,10 +350,10 @@ allprojects {
}
sourceSets.configureEach {
val sourceSet = this
val sourceJarName: String = if ("main".equals(this.name)) "sourceJar" else "${this.name}SourceJar"
val sourceJarName: String = if ("main" == this.name) "sourceJar" else "${this.name}SourceJar"
tasks.register(sourceJarName, Jar::class.java) {
group = "build"
val classifier = if ("main".equals(sourceSet.name)) "sources" else "${sourceSet.name}sources"
val classifier = if ("main" == sourceSet.name) "sources" else "${sourceSet.name}sources"
archiveClassifier.set(classifier)
from(sourceSet.allJava)
}
Expand Down Expand Up @@ -431,7 +431,7 @@ publishing {
artifact(tasks["mixinsSourceJar"])
artifact(tasks["accessorsSourceJar"])
pom {
artifactId = project.name.toLowerCase()
artifactId = project.name.lowercase()
this.name.set(project.name)
this.description.set(project.description)
this.url.set(projectUrl)
Expand Down
6 changes: 3 additions & 3 deletions generator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ indraSpotlessLicenser {
}

val apiBase = rootProject.file("SpongeAPI/src/main/java/")
val temporaryLicenseHeader = project.buildDir.resolve("api-gen-license-header.txt")
val temporaryLicenseHeader = project.layout.buildDirectory.file("api-gen-license-header.txt")
tasks.register("generateApiData", JavaExec::class) {
group = "sponge"
description = "Generate API Catalog classes"
javaLauncher.set(project.javaToolchains.launcherFor(java.toolchain))

classpath(sourceSets.main.map { it.output }, sourceSets.main.map { it.runtimeClasspath })
mainClass.set("org.spongepowered.vanilla.generator.GeneratorMain")
args(apiBase.canonicalPath, temporaryLicenseHeader.canonicalPath)
args(apiBase.canonicalPath, temporaryLicenseHeader.get().asFile.canonicalPath)

doFirst {
// Write a template-expanded license header to the temporary file
Expand All @@ -58,7 +58,7 @@ tasks.register("generateApiData", JavaExec::class) {
propertyMap["name"] = "SpongeAPI"
val out = template.make(propertyMap)

temporaryLicenseHeader.bufferedWriter(Charsets.UTF_8).use { writer ->
temporaryLicenseHeader.get().asFile.bufferedWriter(Charsets.UTF_8).use { writer ->
out.writeTo(writer)
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ vineflowerVersion=1.9.1

org.gradle.jvmargs=-Xss4m
org.gradle.parallel=true
org.gradle.caching=false
org.gradle.caching=false
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-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 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=SC2039,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=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# 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
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# 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, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
14 changes: 7 additions & 7 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ pluginManagement {
plugins {
// Default plugin versions
id("org.spongepowered.gradle.vanilla") version "0.2.1-SNAPSHOT"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("com.github.johnrengelman.shadow") version "8.1.0"
id("org.spongepowered.gradle.sponge.dev") version "2.1.1"
id("net.kyori.indra.licenser.spotless") version "3.0.1"
id("net.kyori.indra.licenser.spotless") version "3.1.3"
id("implementation-structure")
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.6"
id("com.github.ben-manes.versions") version "0.42.0"
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
id("com.github.ben-manes.versions") version "0.49.0"
}
}

plugins {
id("org.spongepowered.gradle.vanilla")
id("org.gradle.toolchains.foojay-resolver-convention") version("0.3.0")
id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
}

dependencyResolutionManagement {
Expand Down Expand Up @@ -54,7 +54,7 @@ if (!file("SpongeAPI/gradle.properties").exists()) {
includeBuild("build-logic")
includeBuild("SpongeAPI") {
dependencySubstitution {
substitute(module("org.spongepowered:spongeapi")).with(project(":"))
substitute(module("org.spongepowered:spongeapi")).using(project(":"))
}
}
include(":SpongeVanilla")
Expand Down Expand Up @@ -116,7 +116,7 @@ if (apiProps.exists()) {
if (key.startsWith("api")) {
extraProperties[key] = value
} else {
extraProperties["api${key.capitalize()}"] = value
extraProperties["api${key.replaceFirstChar { it.uppercase() }}"] = value
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion vanilla/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ publishing {
artifact(tasks["launchSourceJar"])
artifact(tasks["mixinsSourceJar"])
pom {
artifactId = project.name.toLowerCase()
artifactId = project.name.lowercase()
this.name.set(project.name)
this.description.set(project.description)
this.url.set(projectUrl)
Expand Down

0 comments on commit 3f22b74

Please sign in to comment.