diff --git a/build.gradle b/build.gradle index a908e9fc31..e0e3255b5d 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ plugins { id 'maven-publish' id "com.diffplug.spotless" version "6.21.0" id 'net.fabricmc.filament' version "0.7.1" - id 'net.legacyfabric.multifilament' version "0.3.0" apply false + id 'net.legacyfabric.multifilament' version "0.4.0" apply false } def taskName = project.gradle.startParameter.taskNames[0] @@ -42,16 +42,6 @@ apply plugin:"net.legacyfabric.multifilament" def mapJarGroup = "jar mapping" -multiFilament { - intermediaryRevision = intermediary_version.toInteger() - activeMappingsDir = file("mappings-active") - multiMappingsDir = file("mappings") - tempMappingsDir = file("mappings-temp") - it.yarnGroup = "yarn" - it.buildMappingGroup = "mapping build" - it.mapJarGroupGroup = mapJarGroup -} - // Fetch build number from Github Actions def build_number = ENV.GITHUB_RUN_NUMBER && taskName != "publishToMavenLocal" ? ENV.GITHUB_RUN_NUMBER : "local" @@ -67,6 +57,20 @@ if (build_number != "local") { def yarnVersion = "${minecraft_version}+build.$build_number" version = yarnVersion +multiFilament { + intermediaryRevision = intermediary_version.toInteger() + activeMappingsDir = file("mappings-active") + multiMappingsDir = file("mappings") + tempMappingsDir = file("mappings-temp") + it.yarnGroup = "yarn" + it.buildMappingGroup = "mapping build" + it.mapJarGroupGroup = mapJarGroup + it.version = yarnVersion + it.unpickDefinitionsDir = file("unpick-definitions") + it.unpickMetaFile = file("unpick-definitions/unpick.json") + it.unpickVersion = project.unpick_version +} + System.out.println("Preparing yarn ${yarnVersion}") repositories { @@ -85,25 +89,6 @@ repositories { } } -configurations { - asm - enigmaRuntime { - extendsFrom asm - } - javadocClasspath - decompileClasspath - mappingPoetJar { - transitive = false - } - mappingPoet { - extendsFrom mappingPoetJar - extendsFrom asm - transitive = true - } -} - -def unpickMetaFile = file("unpick-definitions/unpick.json") - dependencies { enigmaRuntime "cuchaz:enigma-swing:${project.enigma_version}" enigmaRuntime "net.fabricmc:name-proposal:${project.name_proposal_version}" @@ -126,18 +111,11 @@ import com.diffplug.spotless.LineEnding import cuchaz.enigma.command.CheckMappingsCommand import net.fabricmc.filament.task.MapJarTask import net.fabricmc.filament.task.UnpickJarTask -import net.fabricmc.filament.task.minecraft.MergeMinecraftTask -import net.fabricmc.filament.task.base.WithFileInput -import net.fabricmc.filament.task.base.WithFileOutput -import net.fabricmc.filament.task.enigma.MapSpecializedMethodsTask -import net.fabricmc.filament.task.mappingio.CompleteMappingsTask -import net.fabricmc.filament.task.mappingio.ConvertMappingsTask import net.fabricmc.filament.task.mappingio.MergeMappingsTask import net.fabricmc.mappingio.format.MappingFormat import net.fabricmc.nameproposal.MappingNameCompleter import org.gradle.work.DisableCachingByDefault - -import java.util.zip.GZIPOutputStream +import net.legacyfabric.multifilament.task.FileInputOutput def getIntermediaryGroup() { switch(multiFilament.intermediaryRevision.get()) { @@ -148,40 +126,6 @@ def getIntermediaryGroup() { } } -tasks.register("mergeOriginalMinecraftJars", MergeMinecraftTask) { - dependsOn downloadMinecraftClientJar, downloadMinecraftServerJar - clientJar = downloadMinecraftClientJar.output - serverJar = downloadMinecraftServerJar.output - - output = file(".gradle/filament/${minecraft_version}/merged.jar"); -} - -tasks.register('mapIntermediaryJar', MapJarTask) { - dependsOn downloadIntermediary, ( - multiFilament.isServerBundled() ? mergeMinecraftJars - : mergeOriginalMinecraftJars) - group = mapJarGroup - output = file("${minecraft_version}-intermediary.jar") - input = ( - multiFilament.isServerBundled() ? mergeMinecraftJars - : mergeOriginalMinecraftJars).output - mappings = downloadIntermediary.output - classpath.from minecraftLibraries - from = 'official' - to = 'intermediary' -} - -tasks.register('mapServerIntermediaryJar', MapJarTask) { - dependsOn downloadIntermediary, (multiFilament.isServerBundled() ? extractBundledServer : downloadMinecraftServerJar) - group = mapJarGroup - output = file("${minecraft_version}-server-intermediary.jar") - input = (multiFilament.isServerBundled() ? extractBundledServer : downloadMinecraftServerJar).output - mappings = downloadIntermediary.output - classpath.from minecraftLibraries - from = 'official' - to = 'intermediary' -} - tasks.register('yarn', EnigmaTask) { dependsOn mapIntermediaryJar, versionifyMappingsExclude group = multiFilament.yarnGroup.get() @@ -203,11 +147,12 @@ tasks.register('checkMappings') { inputs.file mapIntermediaryJar.output def intermediaryJarPath = mapIntermediaryJar.outputFile.absolutePath + def activeMappingsDir = multiFilament.activeMappingsDir.asFile.get().getAbsolutePath() doLast { String[] args = [ intermediaryJarPath, - multiFilament.activeMappingsDir.asFile.get().getAbsolutePath() + activeMappingsDir ] try { @@ -218,80 +163,11 @@ tasks.register('checkMappings') { } } -tasks.register('mapSpecializedMethods', MapSpecializedMethodsTask) { - dependsOn versionifyMappingsExclude - intermediaryJarFile = mapIntermediaryJar.output - mappings = multiFilament.activeMappingsDir - output = multiFilament.tempDirectory.file("yarn-specialized-mappings-v2.tiny") - - inputMappingsFormat = "enigma" - outputMappingsFormat = "tinyv2:intermediary:named" -} - -tasks.register('completeMappings', CompleteMappingsTask) { - input = mapSpecializedMethods.output - output = multiFilament.tempDirectory.file("yarn-mappings-v2.tiny") - outputFormat = MappingFormat.TINY_2_FILE -} - -tasks.register('convertToV1', ConvertMappingsTask) { - input = mapSpecializedMethods.output - output = multiFilament.tempDirectory.file("yarn-mappings.tiny") - outputFormat = MappingFormat.TINY_FILE -} - -tasks.register('mergeTiny', MergeMappingsTask) { - group = multiFilament.buildMappingGroup.get() - output = multiFilament.tempDirectory.file("mappings.tiny") - mappingInputs.from downloadIntermediary.output - mappingInputs.from convertToV1.output - outputFormat = MappingFormat.TINY_FILE -} - // Disable the default jar task jar { enabled = false } -tasks.register('tinyJar', Jar) { - dependsOn mergeTiny - group = multiFilament.buildMappingGroup.get() - archiveFileName = "yarn-${yarnVersion}.jar" - destinationDirectory.set(multiFilament.libsDirectory) - archiveClassifier = "" - - from(mergeTiny.output) { - rename { "mappings/mappings.tiny" } - } - manifest { - attributes("Minecraft-Version-Id": minecraft_version) - } -} - -tasks.register('compressTiny', FileInputOutput) { - dependsOn tinyJar, mergeTiny - group = multiFilament.buildMappingGroup.get() - - input = mergeTiny.output - output = multiFilament.libsDirectory.file("yarn-tiny-${yarnVersion}.gz") - - doLast { - def buffer = new byte[1024] - def fileOutputStream = new FileOutputStream(outputFile) - def outputStream = new GZIPOutputStream(fileOutputStream) - def fileInputStream = new FileInputStream(inputFile) - - def length - while ((length = fileInputStream.read(buffer)) > 0) { - outputStream.write(buffer, 0, length) - } - - fileInputStream.close() - outputStream.finish() - outputStream.close() - } -} - clean.doFirst { delete multiFilament.tempDirectory, multiFilament.minecraftCacheDirectory } @@ -308,12 +184,6 @@ tasks.register('constantsJar', Jar) { tasks.build.dependsOn "compressTiny","tinyJar","v2UnmergedYarnJar", "v2MergedYarnJar", "javadocJar" -combineUnpickDefinitions { - group = 'unpick' - input = file('unpick-definitions') - output = multiFilament.tempDirectory.file('definitions.unpick') -} - // Setup the build for the unpicked constants java { @@ -380,7 +250,7 @@ fixedRemapUnpickDefinitionsIntermediary { tasks.register('unpickIntermediaryJar', UnpickJarTask) { group = 'unpick' input = mapIntermediaryJar.output - output = file("${minecraft_version}-intermediary-unpicked.jar") + output = multiFilament.getCacheFile("${minecraft_version}-intermediary-unpicked.jar") unpickDefinition = fixedRemapUnpickDefinitionsIntermediary.output constantsJarFile = constantsJar.archiveFile classpath.from minecraftLibraries @@ -401,54 +271,10 @@ tasks.register('mergeV2', MergeMappingsTask) { outputFormat = MappingFormat.TINY_2_FILE } -tasks.register('v2UnmergedYarnJar', Jar) { - dependsOn insertAutoGeneratedEnumMappings, combineUnpickDefinitions - def mappings = insertAutoGeneratedEnumMappings.output - group = "mapping build" - archiveFileName = "yarn-${yarnVersion}-v2.jar" - - from(file(mappings)) { - rename mappings.get().asFile.name, "mappings/mappings.tiny" - } - from(combineUnpickDefinitions.output) { - rename combineUnpickDefinitions.output.get().asFile.name, "extras/definitions.unpick" - } - from(file(unpickMetaFile)) { - expand version: project.unpick_version - rename unpickMetaFile.name, "extras/unpick.json" - } - destinationDirectory.set(multiFilament.libsDirectory) - manifest { - attributes("Minecraft-Version-Id": minecraft_version) - } -} - -tasks.register('v2MergedYarnJar', Jar) { - dependsOn mergeV2 - def mappings = mergeV2.outputFile - group = "mapping build" - archiveFileName = "yarn-${yarnVersion}-mergedv2.jar" - - from(file(mappings)) { - rename mappings.name, "mappings/mappings.tiny" - } - from(combineUnpickDefinitions.output) { - rename combineUnpickDefinitions.output.get().asFile.name, "extras/definitions.unpick" - } - from(file(unpickMetaFile)) { - expand version: project.unpick_version - rename unpickMetaFile.name, "extras/unpick.json" - } - destinationDirectory.set(multiFilament.libsDirectory) - manifest { - attributes("Minecraft-Version-Id": minecraft_version) - } -} - tasks.register('mapNamedJar', MapJarTask) { dependsOn mergeV2, unpickIntermediaryJar group = mapJarGroup - output = file("${minecraft_version}-named.jar") + output = multiFilament.getCacheFile("${minecraft_version}-named.jar") input = unpickIntermediaryJar.output mappings = mergeV2.output classpath.from minecraftLibraries @@ -487,7 +313,7 @@ tasks.register('genFakeSource', JavaExec) { } tasks.register('decompileCFR', JavaExec) { - def outputDir = file("namedSrc") + def outputDir = multiFilament.getIntermediaryRevisionDirectory().get().dir("namedSrc").getAsFile() dependsOn mapNamedJar mainClass = "org.benf.cfr.reader.Main" @@ -609,42 +435,44 @@ javadocLint { check.dependsOn javadocLint -publishing { - publications { - register("maven", MavenPublication) { - groupId "net.legacyfabric" + getIntermediaryGroup() - artifactId "yarn" - version yarnVersion - - artifact(compressTiny.output) { - classifier "tiny" - builtBy compressTiny - } - artifact(tinyJar) - artifact(v2UnmergedYarnJar) { - classifier "v2" - } - artifact(v2MergedYarnJar) { - classifier "mergedv2" - } - artifact(constantsJar) { - classifier "constants" +afterEvaluate { + publishing { + publications { + register("maven", MavenPublication) { + groupId "net.legacyfabric" + getIntermediaryGroup() + artifactId "yarn" + version yarnVersion + + artifact(compressTiny.output) { + classifier "tiny" + builtBy compressTiny + } + artifact(tinyJar) + artifact(v2UnmergedYarnJar) { + classifier "v2" + } + artifact(v2MergedYarnJar) { + classifier "mergedv2" + } + artifact(constantsJar) { + classifier "constants" + } + artifact sourcesJar + artifact javadocJar } - artifact sourcesJar - artifact javadocJar - } - } - repositories { - if (ENV.MAVEN_PUBLISH_CREDENTIALS) { - maven { - url "https://repo.legacyfabric.net/repository/legacyfabric" - credentials { - username ENV.MAVEN_PUBLISH_CREDENTIALS.split(":")[0] - password ENV.MAVEN_PUBLISH_CREDENTIALS.split(":")[1] - } - authentication { - basic(BasicAuthentication) + } + repositories { + if (ENV.MAVEN_PUBLISH_CREDENTIALS) { + maven { + url "https://repo.legacyfabric.net/repository/legacyfabric" + credentials { + username ENV.MAVEN_PUBLISH_CREDENTIALS.split(":")[0] + password ENV.MAVEN_PUBLISH_CREDENTIALS.split(":")[1] + } + authentication { + basic(BasicAuthentication) + } } } } @@ -674,9 +502,6 @@ int getLastBuildNumber() { return metadata[0].build; } -abstract class FileInputOutput extends DefaultTask implements WithFileInput, WithFileOutput { -} - @DisableCachingByDefault abstract class EnigmaTask extends JavaExec { @InputFile diff --git a/test-mod/build.gradle b/test-mod/build.gradle index 47fda871c3..47e298cd81 100644 --- a/test-mod/build.gradle +++ b/test-mod/build.gradle @@ -1,12 +1,13 @@ plugins { - id 'fabric-loom' version "1.3-SNAPSHOT" - id 'legacy-looming' version "1.3-SNAPSHOT" + id 'fabric-loom' version "1.7-SNAPSHOT" + id 'legacy-looming' version "1.7-SNAPSHOT" id 'maven-publish' } def ENV = System.getenv() def minecraft_version = ENV.MC_VERSION ? ENV.MC_VERSION : "1.8.9" +base.archivesName = project.archives_base_name version = project.mod_version group = project.maven_group @@ -64,14 +65,10 @@ legacyLooming { dependencies { minecraft "com.mojang:minecraft:${minecraft_version}" - mappings legacy.yarn(minecraft_version, "local") + mappings(legacy.yarn(minecraft_version, "local")) modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" } -base { - archivesName = project.archives_base_name -} - processResources { inputs.property "version", project.version @@ -80,18 +77,21 @@ processResources { } } -// ensure that the encoding is set to UTF-8, no matter what the system default is -// this fixes some edge cases with special characters not displaying correctly -// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html tasks.withType(JavaCompile).configureEach { + // Ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html it.options.encoding = "UTF-8" - if (JavaVersion.current().isJava9Compatible()) it.options.release = 8 - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 + if (JavaVersion.current().isJava9Compatible()) { + it.options.release = 8 + } } java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // if it is present. // If you remove this line, sources will not be generated. @@ -100,11 +100,11 @@ java { jar { from("LICENSE") { - rename { "${it}_${base.archivesName.get()}"} + rename { "${it}_${base.archivesName.get()}" } } } -// configure the maven publication +// Configure the maven publication publishing { publications { mavenJava(MavenPublication) { @@ -112,9 +112,9 @@ publishing { } } - // select the repositories you want to publish to + // Select the repositories you want to publish to repositories { - // uncomment to publish to the local maven + // Uncomment to publish to the local maven // mavenLocal() } } diff --git a/test-mod/gradle.properties b/test-mod/gradle.properties index a024e32697..3532862391 100644 --- a/test-mod/gradle.properties +++ b/test-mod/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties - loader_version = 0.14.21 + loader_version = 0.15.11 # Mod Properties mod_version = 1.0.0 diff --git a/test-mod/gradle/wrapper/gradle-wrapper.jar b/test-mod/gradle/wrapper/gradle-wrapper.jar index c1962a79e2..d64cd49177 100644 Binary files a/test-mod/gradle/wrapper/gradle-wrapper.jar and b/test-mod/gradle/wrapper/gradle-wrapper.jar differ diff --git a/test-mod/gradle/wrapper/gradle-wrapper.properties b/test-mod/gradle/wrapper/gradle-wrapper.properties index 37aef8d3f0..a4413138c9 100644 --- a/test-mod/gradle/wrapper/gradle-wrapper.properties +++ b/test-mod/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/test-mod/gradlew b/test-mod/gradlew index aeb74cbb43..1aa94a4269 100755 --- a/test-mod/gradlew +++ b/test-mod/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# 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 @@ -130,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. @@ -141,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 @@ -149,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 @@ -198,11 +202,11 @@ 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 -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. +# 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" \