Skip to content

Commit 3f22b74

Browse files
ImMorpheuszml2008
andauthored
Bump to gradle 8.4 (SpongePowered#3916)
* 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]>
1 parent d03fa69 commit 3f22b74

File tree

10 files changed

+67
-43
lines changed

10 files changed

+67
-43
lines changed

build-logic/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ indra {
1111

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

1717
indraSpotlessLicenser {

build-logic/src/main/java/org/spongepowered/gradle/impl/OutputDependenciesToJson.java

+31-13
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,16 @@
2929
import org.gradle.api.DefaultTask;
3030
import org.gradle.api.GradleException;
3131
import org.gradle.api.NamedDomainObjectProvider;
32-
import org.gradle.api.artifacts.ArtifactCollection;
3332
import org.gradle.api.artifacts.Configuration;
3433
import org.gradle.api.artifacts.component.ComponentIdentifier;
3534
import org.gradle.api.artifacts.component.ModuleComponentIdentifier;
3635
import org.gradle.api.artifacts.result.ResolvedArtifactResult;
3736
import org.gradle.api.file.RegularFileProperty;
3837
import org.gradle.api.provider.MapProperty;
39-
import org.gradle.api.provider.Property;
38+
import org.gradle.api.provider.Provider;
4039
import org.gradle.api.provider.SetProperty;
4140
import org.gradle.api.tasks.Input;
42-
import org.gradle.api.tasks.InputFiles;
41+
import org.gradle.api.tasks.Internal;
4342
import org.gradle.api.tasks.Nested;
4443
import org.gradle.api.tasks.Optional;
4544
import org.gradle.api.tasks.OutputFile;
@@ -161,12 +160,15 @@ public final void dependencies(final String key, final NamedDomainObjectProvider
161160
* Excludes configuration, to remove certain entries from dependencies and
162161
* transitive dependencies of {@link #getDependencies()}.
163162
*/
163+
@Internal
164+
public abstract SetProperty<ResolvedArtifactResult> getExcludedDependencies();
165+
164166
@Input
165167
@Optional
166-
public abstract Property<Configuration> getExcludedDependencies();
168+
protected abstract SetProperty<ModuleComponentIdentifier> getExcludedDependenciesBuildInput();
167169

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

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

181183
public OutputDependenciesToJson() {
182184
this.getAllowedClassifiers().add("");
185+
this.getExcludedDependenciesBuildInput().set(this.getExcludedDependencies().map(deps -> {
186+
return deps.stream()
187+
.map(res -> res.getId().getComponentIdentifier())
188+
.filter(res -> res instanceof ModuleComponentIdentifier)
189+
.map(res -> (ModuleComponentIdentifier) res)
190+
.collect(Collectors.toSet());
191+
}));
183192
}
184193

185194
@TaskAction
186195
public void generateDependenciesJson() {
187196
final Set<ModuleComponentIdentifier> excludedDeps = new HashSet<>();
188197
if (this.getExcludedDependencies().isPresent()) {
189-
for (final ResolvedArtifactResult result : this.getExcludedDependencies().get().getIncoming().getArtifacts()) {
198+
for (final ResolvedArtifactResult result : this.getExcludedDependencies().get()) {
190199
if (result.getId().getComponentIdentifier() instanceof ModuleComponentIdentifier) {
191200
excludedDeps.add((ModuleComponentIdentifier) result.getId().getComponentIdentifier());
192201
}
@@ -197,7 +206,7 @@ public void generateDependenciesJson() {
197206
final Map<String, List<DependencyDescriptor>> dependenciesMap = new TreeMap<>();
198207

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

@@ -212,8 +221,8 @@ public void generateDependenciesJson() {
212221
}
213222
}
214223

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

262271
public static class ConfigurationHolder {
263-
private final Configuration configuration;
272+
private final Provider<Set<ResolvedArtifactResult>> configuration;
264273

265274
public ConfigurationHolder(final Configuration configuration) {
266-
this.configuration = configuration;
275+
this.configuration = configuration.getIncoming().getArtifacts().getResolvedArtifacts();
276+
}
277+
278+
@Input
279+
public Provider<Set<ModuleComponentIdentifier>> getIds() {
280+
return this.getArtifacts().map(set -> set.stream()
281+
.map(art -> art.getId().getComponentIdentifier())
282+
.filter(id -> id instanceof ModuleComponentIdentifier)
283+
.map(art -> (ModuleComponentIdentifier) art)
284+
.collect(Collectors.toSet()));
267285
}
268286

269-
@InputFiles
270-
public Configuration getConfiguration() {
287+
@Internal
288+
public Provider<Set<ResolvedArtifactResult>> getArtifacts() {
271289
return this.configuration;
272290
}
273291
}

build.gradle.kts

+4-4
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ allprojects {
249249
apply(plugin = "net.kyori.indra.licenser.spotless")
250250

251251
base {
252-
archivesBaseName = name.toLowerCase(Locale.ENGLISH)
252+
archivesName = name.lowercase(Locale.ENGLISH)
253253
}
254254

255255
plugins.withId("org.spongepowered.gradle.vanilla") {
@@ -350,10 +350,10 @@ allprojects {
350350
}
351351
sourceSets.configureEach {
352352
val sourceSet = this
353-
val sourceJarName: String = if ("main".equals(this.name)) "sourceJar" else "${this.name}SourceJar"
353+
val sourceJarName: String = if ("main" == this.name) "sourceJar" else "${this.name}SourceJar"
354354
tasks.register(sourceJarName, Jar::class.java) {
355355
group = "build"
356-
val classifier = if ("main".equals(sourceSet.name)) "sources" else "${sourceSet.name}sources"
356+
val classifier = if ("main" == sourceSet.name) "sources" else "${sourceSet.name}sources"
357357
archiveClassifier.set(classifier)
358358
from(sourceSet.allJava)
359359
}
@@ -431,7 +431,7 @@ publishing {
431431
artifact(tasks["mixinsSourceJar"])
432432
artifact(tasks["accessorsSourceJar"])
433433
pom {
434-
artifactId = project.name.toLowerCase()
434+
artifactId = project.name.lowercase()
435435
this.name.set(project.name)
436436
this.description.set(project.description)
437437
this.url.set(projectUrl)

generator/build.gradle.kts

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ indraSpotlessLicenser {
3939
}
4040

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

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

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

61-
temporaryLicenseHeader.bufferedWriter(Charsets.UTF_8).use { writer ->
61+
temporaryLicenseHeader.get().asFile.bufferedWriter(Charsets.UTF_8).use { writer ->
6262
out.writeTo(writer)
6363
}
6464
}

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ vineflowerVersion=1.9.1
2929

3030
org.gradle.jvmargs=-Xss4m
3131
org.gradle.parallel=true
32-
org.gradle.caching=false
32+
org.gradle.caching=false

gradle/wrapper/gradle-wrapper.jar

2.1 KB
Binary file not shown.
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
44
networkTimeout=10000
5+
validateDistributionUrl=true
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

gradlew

+17-12
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,8 @@ done
8383
# This is normally unused
8484
# shellcheck disable=SC2034
8585
APP_BASE_NAME=${0##*/}
86-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,26 +131,29 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
143144
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
146147
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147-
# shellcheck disable=SC3045
148+
# shellcheck disable=SC2039,SC3045
148149
MAX_FD=$( ulimit -H -n ) ||
149150
warn "Could not query maximum file descriptor limit"
150151
esac
151152
case $MAX_FD in #(
152153
'' | soft) :;; #(
153154
*)
154155
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155-
# shellcheck disable=SC3045
156+
# shellcheck disable=SC2039,SC3045
156157
ulimit -n "$MAX_FD" ||
157158
warn "Could not set maximum file descriptor limit to $MAX_FD"
158159
esac
@@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
197198
done
198199
fi
199200

200-
# Collect all arguments for the java command;
201-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202-
# shell script including quotes and variable substitutions, so put them in
203-
# double quotes to make sure that they get re-expanded; and
204-
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
205210

206211
set -- \
207212
"-Dorg.gradle.appname=$APP_BASE_NAME" \

settings.gradle.kts

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ pluginManagement {
1010
plugins {
1111
// Default plugin versions
1212
id("org.spongepowered.gradle.vanilla") version "0.2.1-SNAPSHOT"
13-
id("com.github.johnrengelman.shadow") version "7.1.2"
13+
id("com.github.johnrengelman.shadow") version "8.1.0"
1414
id("org.spongepowered.gradle.sponge.dev") version "2.1.1"
15-
id("net.kyori.indra.licenser.spotless") version "3.0.1"
15+
id("net.kyori.indra.licenser.spotless") version "3.1.3"
1616
id("implementation-structure")
17-
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.6"
18-
id("com.github.ben-manes.versions") version "0.42.0"
17+
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
18+
id("com.github.ben-manes.versions") version "0.49.0"
1919
}
2020
}
2121

2222
plugins {
2323
id("org.spongepowered.gradle.vanilla")
24-
id("org.gradle.toolchains.foojay-resolver-convention") version("0.3.0")
24+
id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0")
2525
}
2626

2727
dependencyResolutionManagement {
@@ -54,7 +54,7 @@ if (!file("SpongeAPI/gradle.properties").exists()) {
5454
includeBuild("build-logic")
5555
includeBuild("SpongeAPI") {
5656
dependencySubstitution {
57-
substitute(module("org.spongepowered:spongeapi")).with(project(":"))
57+
substitute(module("org.spongepowered:spongeapi")).using(project(":"))
5858
}
5959
}
6060
include(":SpongeVanilla")
@@ -116,7 +116,7 @@ if (apiProps.exists()) {
116116
if (key.startsWith("api")) {
117117
extraProperties[key] = value
118118
} else {
119-
extraProperties["api${key.capitalize()}"] = value
119+
extraProperties["api${key.replaceFirstChar { it.uppercase() }}"] = value
120120
}
121121
}
122122
}

vanilla/build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ publishing {
539539
artifact(tasks["launchSourceJar"])
540540
artifact(tasks["mixinsSourceJar"])
541541
pom {
542-
artifactId = project.name.toLowerCase()
542+
artifactId = project.name.lowercase()
543543
this.name.set(project.name)
544544
this.description.set(project.description)
545545
this.url.set(projectUrl)

0 commit comments

Comments
 (0)