diff --git a/build-logic/build.gradle b/build-logic/build.gradle index 1bac6a6e29e..62501a681f3 100644 --- a/build-logic/build.gradle +++ b/build-logic/build.gradle @@ -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 { diff --git a/build-logic/src/main/java/org/spongepowered/gradle/impl/OutputDependenciesToJson.java b/build-logic/src/main/java/org/spongepowered/gradle/impl/OutputDependenciesToJson.java index e219b3ae042..58c9cb7a789 100644 --- a/build-logic/src/main/java/org/spongepowered/gradle/impl/OutputDependenciesToJson.java +++ b/build-logic/src/main/java/org/spongepowered/gradle/impl/OutputDependenciesToJson.java @@ -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; @@ -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 getExcludedDependencies(); + @Input @Optional - public abstract Property getExcludedDependencies(); + protected abstract SetProperty getExcludedDependenciesBuildInput(); public final void excludedDependencies(final NamedDomainObjectProvider config) { - this.getExcludedDependencies().set(config); + this.getExcludedDependencies().set(config.flatMap(conf -> conf.getIncoming().getArtifacts().getResolvedArtifacts())); } /** @@ -180,13 +182,20 @@ public final void excludedDependencies(final NamedDomainObjectProvider { + 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 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()); } @@ -197,7 +206,7 @@ public void generateDependenciesJson() { final Map> dependenciesMap = new TreeMap<>(); for (final Map.Entry 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); @@ -212,8 +221,8 @@ public void generateDependenciesJson() { } } - private List configToDescriptor(final ArtifactCollection conf, final Set excludedDeps) { - return conf.getArtifacts().stream() + private List configToDescriptor(final Set conf, final Set excludedDeps) { + return conf.stream() .filter(dep -> { final ComponentIdentifier ident = dep.getId().getComponentIdentifier(); return ident instanceof ModuleComponentIdentifier && !excludedDeps.contains(ident); @@ -260,14 +269,23 @@ public static String toHexString(final byte[] bytes) { } public static class ConfigurationHolder { - private final Configuration configuration; + private final Provider> configuration; public ConfigurationHolder(final Configuration configuration) { - this.configuration = configuration; + this.configuration = configuration.getIncoming().getArtifacts().getResolvedArtifacts(); + } + + @Input + public Provider> 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> getArtifacts() { return this.configuration; } } diff --git a/build.gradle.kts b/build.gradle.kts index 68020ff7870..3176afc0683 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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") { @@ -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) } @@ -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) diff --git a/generator/build.gradle.kts b/generator/build.gradle.kts index 04e8d3a217b..e45a2fcaff2 100644 --- a/generator/build.gradle.kts +++ b/generator/build.gradle.kts @@ -39,7 +39,7 @@ 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" @@ -47,7 +47,7 @@ tasks.register("generateApiData", JavaExec::class) { 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 @@ -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) } } diff --git a/gradle.properties b/gradle.properties index aae8d7758d0..c39642be38e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -29,4 +29,4 @@ vineflowerVersion=1.9.1 org.gradle.jvmargs=-Xss4m org.gradle.parallel=true -org.gradle.caching=false +org.gradle.caching=false \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 943f0cbfa75..7f93135c49b 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 f398c33c4b0..3fa8f862f75 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-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 65dcd68d65c..1aa94a42690 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=SC2039,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=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -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" \ diff --git a/settings.gradle.kts b/settings.gradle.kts index 63b1dbcb2ff..ae5f7797ccd 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -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 { @@ -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") @@ -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 } } } diff --git a/vanilla/build.gradle.kts b/vanilla/build.gradle.kts index 8e3ec4068cc..66bdd24158a 100644 --- a/vanilla/build.gradle.kts +++ b/vanilla/build.gradle.kts @@ -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)