diff --git a/build.gradle b/build.gradle index c807443994..f508b68031 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import quilt.internal.tasks.build.MappingsV2JarTask + buildscript { repositories { maven { @@ -29,13 +31,13 @@ plugins { id 'java' // for constants, packages, javadoc id 'maven-publish' id 'org.cadixdev.licenser' version '0.6.1' - id "mappings-logic" + id "quilt-mappings" } -mappings { - enigmaProfile = file('enigma_profile.json') +quiltMappings { + enigmaProfileConfig = file('enigma/enigma_profile.json') - unpick = file('unpick/unpick.json') + unpickMeta = file('unpick/unpick.json') } combineUnpickDefinitions { @@ -118,8 +120,8 @@ import quilt.internal.util.MappingsJavadocProvider // TODO consider moving cleanable things to build/ so this isn't necessary, // or put them in .gradle/cleanable/ and only add that here (or MappingsPlugin) clean.doFirst { - delete mappings.fileConstants.tempDir, mappings.fileConstants.cacheFilesMinecraft - // , mappings.fileConstants.generatedUnpickDefinitions + delete quiltMappings.fileConstants.tempDir, quiltMappings.fileConstants.cacheFilesMinecraft + // , quiltMappings.fileConstants.generatedUnpickDefinitions } tasks.build.dependsOn "compressTiny", "tinyJar", "v2UnmergedMappingsJar", "v2MergedMappingsJar" @@ -161,7 +163,7 @@ task mappingsUnpicked(type: EnigmaMappingsTask, dependsOn: unpickHashedJar) { } task mappings(type: EnigmaMappingsTask, dependsOn: "mapPerVersionMappingsJar") { - jarToMap.set mappings.fileConstants.perVersionMappingsJar + jarToMap.set quiltMappings.fileConstants.perVersionMappingsJar } task mappingsUnpickedServer(type: EnigmaMappingsServerTask, dependsOn: unpickHashedJar) { @@ -169,23 +171,15 @@ task mappingsUnpickedServer(type: EnigmaMappingsServerTask, dependsOn: unpickHas } task mappingsServer(type: EnigmaMappingsServerTask, dependsOn: "mapPerVersionMappingsJar") { - jarToMap.set project.extensions.mappings.fileConstants.perVersionMappingsJar + jarToMap.set project.extensions.quiltMappings.fileConstants.perVersionMappingsJar } // Only build jars for package infos if we need to actually expose stuff like annotation in the future. build.dependsOn constantsJar, generatePackageInfoMappings -task buildIntermediary { - dependsOn intermediaryV2MappingsJar, intermediaryV2MergedMappingsJar - - onlyIf { - return checkIntermediaryMappings.isPresent() - } -} - task eraseBytecode(type: TransformJarClassesTask, dependsOn: mapNamedJar) { - jarFile = mappings.fileConstants.namedJar + jarFile = quiltMappings.fileConstants.namedJar output = file(".gradle/temp/erased-classes/") visitor(DraftsmanAdapterClassVisitor::new) @@ -219,7 +213,7 @@ task genFakeSource(type: DecompileTask, dependsOn: [mergeTinyV2, eraseBytecode]) input = eraseBytecode.output.asFile.get() output = fakeSourceDir decompiler = Decompilers.VINEFLOWER - libraries = files(mappings.fileConstants.libraries) + libraries = files(quiltMappings.fileConstants.libraries) decompilerOptions = [ "rsy": "1", // remove synthetics "dgs": "1", // decompile generic signatures @@ -243,7 +237,7 @@ task genFakeSource(type: DecompileTask, dependsOn: [mergeTinyV2, eraseBytecode]) } task decompileVineflower(type: DecompileTask, dependsOn: [mapNamedJar]) { - input.set mappings.fileConstants.namedJar + input.set quiltMappings.fileConstants.namedJar output.set file("namedSrc") decompiler = Decompilers.VINEFLOWER libraries = files(configurations.decompileClasspath) @@ -350,7 +344,7 @@ generatePackageInfoMappings { mappingLint { dependsOn mapPerVersionMappingsJar mappingDirectory = file("mappings") - jarFile = mappings.fileConstants.perVersionMappingsJar + jarFile = quiltMappings.fileConstants.perVersionMappingsJar } check.dependsOn mappingLint diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index a88b3c3893..c3c9db0e78 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -86,9 +86,9 @@ test { gradlePlugin { plugins { - mappingsLogic { - id = 'mappings-logic' - implementationClass = 'quilt.internal.MappingsPlugin' + quiltMappings { + id = 'quilt-mappings' + implementationClass = 'quilt.internal.QuiltMappingsPlugin' } } } \ No newline at end of file diff --git a/buildSrc/src/main/java/quilt/internal/MappingsExtension.java b/buildSrc/src/main/java/quilt/internal/QuiltMappingsExtension.java similarity index 53% rename from buildSrc/src/main/java/quilt/internal/MappingsExtension.java rename to buildSrc/src/main/java/quilt/internal/QuiltMappingsExtension.java index 691bab002c..99aca41eb5 100644 --- a/buildSrc/src/main/java/quilt/internal/MappingsExtension.java +++ b/buildSrc/src/main/java/quilt/internal/QuiltMappingsExtension.java @@ -2,7 +2,6 @@ import org.gradle.api.GradleException; import org.gradle.api.Project; -import org.gradle.api.file.DirectoryProperty; import org.gradle.api.file.RegularFile; import org.gradle.api.file.RegularFileProperty; import org.gradle.api.provider.Provider; @@ -11,28 +10,30 @@ import java.io.File; import java.io.IOException; -public abstract class MappingsExtension { +public abstract class QuiltMappingsExtension { + public static final String EXTENSION_NAME = "quiltMappings"; + // TODO see if this can use a BuildService /** - * {@link MappingsPlugin} configures all + * {@link QuiltMappingsPlugin} configures all * {@link quilt.internal.tasks.EnigmaProfileConsumingTask EnigmaProfileConsumingTask}s to use this profile. */ public final Provider enigmaProfile; - public abstract RegularFileProperty getUnpick(); + public abstract RegularFileProperty getUnpickMeta(); private final FileConstants fileConstants; - public static MappingsExtension get(Project project) { - return project.getExtensions().getByType(MappingsExtension.class); + public static QuiltMappingsExtension get(Project project) { + return project.getExtensions().getByType(QuiltMappingsExtension.class); } - protected abstract RegularFileProperty getEnigmaProfileFile(); + protected abstract RegularFileProperty getEnigmaProfileConfigImpl(); - public MappingsExtension(Project project) { + public QuiltMappingsExtension(Project project) { this.fileConstants = new FileConstants(project); - this.enigmaProfile = this.getEnigmaProfileFile() + this.enigmaProfile = this.getEnigmaProfileConfigImpl() .map(RegularFile::getAsFile) .map(File::toPath) .map(profilePath -> { @@ -48,15 +49,16 @@ public FileConstants getFileConstants() { return this.fileConstants; } - public void setEnigmaProfile(File file) { - this.getEnigmaProfileFile().set(file); + // TODO is there a cleaner way to only expose setters? + public void setEnigmaProfileConfig(File file) { + this.getEnigmaProfileConfigImpl().set(file); } - public void setEnigmaProfile(RegularFile file) { - this.getEnigmaProfileFile().set(file); + public void setEnigmaProfileConfig(RegularFile file) { + this.getEnigmaProfileConfigImpl().set(file); } - public void setEnigmaProfile(Provider fileProvider) { - this.getEnigmaProfileFile().set(fileProvider); + public void setEnigmaProfileConfig(Provider fileProvider) { + this.getEnigmaProfileConfigImpl().set(fileProvider); } } diff --git a/buildSrc/src/main/java/quilt/internal/MappingsPlugin.java b/buildSrc/src/main/java/quilt/internal/QuiltMappingsPlugin.java similarity index 90% rename from buildSrc/src/main/java/quilt/internal/MappingsPlugin.java rename to buildSrc/src/main/java/quilt/internal/QuiltMappingsPlugin.java index c49904f419..41206d3f07 100644 --- a/buildSrc/src/main/java/quilt/internal/MappingsPlugin.java +++ b/buildSrc/src/main/java/quilt/internal/QuiltMappingsPlugin.java @@ -1,5 +1,6 @@ package quilt.internal; +import org.gradle.api.DefaultTask; import org.gradle.api.GradleException; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -65,7 +66,11 @@ import static quilt.internal.util.ProviderUtil.provideProjectDir; // TODO extract common providers, possibly convert FileConstants to providers instead of files -public abstract class MappingsPlugin implements Plugin { + +/** + * TODO javadoc, including every configureEach + */ +public abstract class QuiltMappingsPlugin implements Plugin { public static final String INSERT_AUTO_GENERATED_MAPPINGS_TASK_NAME = "insertAutoGeneratedMappings"; public static final String DOWNLOAD_PER_VERSION_MAPPINGS_TASK_NAME = "downloadPerVersionMappings"; public static final String EXTRACT_TINY_PER_VERSION_MAPPINGS_TASK_NAME = "extractTinyPerVersionMappings"; @@ -76,6 +81,9 @@ public abstract class MappingsPlugin implements Plugin { public static final String CONSTANTS_SOURCE_SET_NAME = "constants"; + public static final String ARCHIVE_FILE_NAME_PREFIX = + Constants.MAPPINGS_NAME + "-" + Constants.MAPPINGS_VERSION + "-"; + public static final String DECOMPILE_TARGET_VINEFLOWER_TASK_NAME = "decompileTargetVineflower"; public static final String CONSTANTS_JAR_TASK_NAME = "constantsJar"; public static final String UNPICK_HASHED_JAR_TASK_NAME = "unpickHashedJar"; @@ -83,8 +91,7 @@ public abstract class MappingsPlugin implements Plugin { public static final String V_2_MERGED_MAPPINGS_JAR_TASK_NAME = "v2MergedMappingsJar"; public static final String INTERMEDIARY_V_2_MAPPINGS_JAR_TASK_NAME = "intermediaryV2MappingsJar"; public static final String INTERMEDIARY_V_2_MERGED_MAPPINGS_JAR_TASK_NAME = "intermediaryV2MergedMappingsJar"; - public static final String ARCHIVE_FILE_NAME_PREFIX = - Constants.MAPPINGS_NAME + "-" + Constants.MAPPINGS_VERSION + "-"; + public static final String BUILD_INTERMEDIARY_TASK_NAME = "buildIntermediary"; private static final String QUILT_MAPPINGS_PREFIX = "quilt-mappings-"; @@ -103,7 +110,7 @@ public void apply(@NotNull Project project) { // has sourceSets final var javaExt = extensions.getByType(JavaPluginExtension.class); - final var ext = extensions.create("mappings", MappingsExtension.class, project); + final var ext = extensions.create(QuiltMappingsExtension.EXTENSION_NAME, QuiltMappingsExtension.class, project); final TaskContainer tasks = project.getTasks(); @@ -115,7 +122,7 @@ public void apply(@NotNull Project project) { ); // provide an informative error message if no profile is specified - ext.getEnigmaProfileFile().convention(() -> { + ext.getEnigmaProfileConfigImpl().convention(() -> { throw new GradleException( "No enigma profile specified. " + "A profile must be specified to use an EnigmaProfileConsumingTask." @@ -293,20 +300,16 @@ public void apply(@NotNull Project project) { task.getUnpickGlStateManagerDefinitions().convention( buildDirProvider.map(dir -> dir.file("unpick_glstatemanager.unpick")) - // ext.getFileConstants().generatedUnpickDefinitions.map(dir -> dir.file("unpick_glstatemanager.unpick")) ); task.getUnpickGlDefinitions().convention( buildDirProvider.map(dir -> dir.file("unpick_gl.unpick")) - // ext.getFileConstants().generatedUnpickDefinitions.map(dir -> dir.file("unpick_gl.unpick")) ); }); final var combineUnpickDefinitions = tasks.register( CombineUnpickDefinitionsTask.TASK_NAME, CombineUnpickDefinitionsTask.class, task -> { - // task.getUnpickDefinitions().builtBy(project.getTasks().withType(UnpickGenTask.class)); - task.getUnpickDefinitions().from(project.provider(() -> project.getTasks().withType(UnpickGenTask.class).stream() .map(UnpickGenTask::getGeneratedUnpickDefinitions) @@ -343,6 +346,9 @@ public void apply(@NotNull Project project) { final var downloadIntermediaryMappings = tasks.register( DownloadIntermediaryMappingsTask.TASK_NAME, DownloadIntermediaryMappingsTask.class, task -> { + // TODO eliminate this + task.dependsOn(checkIntermediaryMappings); + task.getMappingsConfiguration().convention( project.getConfigurations().named(Constants.INTERMEDIARY_MAPPINGS_NAME) ); @@ -350,13 +356,22 @@ public void apply(@NotNull Project project) { provideMappingsDestFile(mappingsDestDir, Constants.INTERMEDIARY_MAPPINGS_NAME, "jar") ); - task.dependsOn(checkIntermediaryMappings); task.onlyIf(unused -> checkIntermediaryMappings.get().isPresent()); } ); final var removeIntermediary = tasks.register(RemoveIntermediaryTask.TASK_NAME, RemoveIntermediaryTask.class); + tasks.withType(MappingsV2JarTask.class).configureEach(task -> { + task.getUnpickMeta().convention(ext.getUnpickMeta()); + + task.getUnpickDefinition().convention( + combineUnpickDefinitions.flatMap(CombineUnpickDefinitionsTask::getOutput) + ); + + task.getDestinationDirectory().convention(project.getLayout().getBuildDirectory().dir("libs")); + }); + tasks.register(V_2_UNMERGED_MAPPINGS_JAR_TASK_NAME, MappingsV2JarTask.class, task -> { task.getMappings().convention( insertAutoGeneratedMappings.flatMap(AddProposedMappingsTask::getOutputMappings) @@ -365,15 +380,19 @@ public void apply(@NotNull Project project) { task.getArchiveFileName().convention(ARCHIVE_FILE_NAME_PREFIX + "v2.jar"); }); - tasks.register(INTERMEDIARY_V_2_MAPPINGS_JAR_TASK_NAME, MappingsV2JarTask.class, task -> { - task.getArchiveFileName().convention(ARCHIVE_FILE_NAME_PREFIX + "intermediary-v2.jar"); + final var intermediaryV2MappingsJar = tasks.register( + INTERMEDIARY_V_2_MAPPINGS_JAR_TASK_NAME, MappingsV2JarTask.class, + task -> { + // TODO eliminate this + task.dependsOn(checkIntermediaryMappings); + + task.getMappings().convention(removeIntermediary.flatMap(RemoveIntermediaryTask::getOutputMappings)); - task.getMappings().convention(removeIntermediary.flatMap(RemoveIntermediaryTask::getOutputMappings)); + task.getArchiveFileName().convention(ARCHIVE_FILE_NAME_PREFIX + "intermediary-v2.jar"); - task.onlyIf(unused -> - checkIntermediaryMappings.map(CheckIntermediaryMappingsTask::isPresent).getOrElse(false) - ); - }); + task.onlyIf(unused -> checkIntermediaryMappings.get().isPresent()); + } + ); final var mergeTinyV2 = tasks.register(MergeTinyV2Task.TASK_NAME, MergeTinyV2Task.class, task -> { // TODO this used to be dependent on v2UnmergedMappingsJar, but afaict it has no effect on this task @@ -446,7 +465,8 @@ public void apply(@NotNull Project project) { final var mergeIntermediary = tasks.register( MergeIntermediaryTask.TASK_NAME, MergeIntermediaryTask.class, task -> { - task.onlyIf(unused -> checkIntermediaryMappings.get().isPresent()); + // TODO eliminate this + task.dependsOn(checkIntermediaryMappings); task.getInput().convention( extractTinyIntermediaryMappings.flatMap(ExtractTinyMappingsTask::getTinyFile) @@ -457,19 +477,27 @@ public void apply(@NotNull Project project) { task.getOutputMappings().convention(() -> new File(ext.getFileConstants().buildDir, "mappings-intermediaryMerged.tiny") ); + + task.onlyIf(unused -> checkIntermediaryMappings.get().isPresent()); } ); - tasks.register(INTERMEDIARY_V_2_MERGED_MAPPINGS_JAR_TASK_NAME, MappingsV2JarTask.class, task -> { - task.dependsOn(mergeIntermediary); + final var intermediaryV2MergedMappingsJar = tasks.register( + INTERMEDIARY_V_2_MERGED_MAPPINGS_JAR_TASK_NAME, MappingsV2JarTask.class, + task -> { + // TODO eliminate this + task.dependsOn(checkIntermediaryMappings); - task.getArchiveFileName().convention(ARCHIVE_FILE_NAME_PREFIX + "intermediary-mergedv2.jar"); + task.getArchiveFileName().convention(ARCHIVE_FILE_NAME_PREFIX + "intermediary-mergedv2.jar"); - task.getMappings().convention(mergeIntermediary.flatMap(MergeIntermediaryTask::getOutputMappings)); + task.getMappings().convention(mergeIntermediary.flatMap(MergeIntermediaryTask::getOutputMappings)); - task.onlyIf(unused -> - checkIntermediaryMappings.map(CheckIntermediaryMappingsTask::isPresent).getOrElse(false) - ); + task.onlyIf(unused -> checkIntermediaryMappings.get().isPresent()); + } + ); + + tasks.register(BUILD_INTERMEDIARY_TASK_NAME, DefaultTask.class, task -> { + task.dependsOn(intermediaryV2MappingsJar, intermediaryV2MergedMappingsJar); }); final var checkTargetVersionExists = tasks.register( @@ -503,7 +531,7 @@ public void apply(@NotNull Project project) { )); task.getTargetJar().convention(task.provideVersionedProjectFile(version -> - Path.of(MappingsPlugin.TARGET_MAPPINGS_DIR, "quilt-mappings-" + version + "-v2.jar") + Path.of(QuiltMappingsPlugin.TARGET_MAPPINGS_DIR, "quilt-mappings-" + version + "-v2.jar") )); } ); @@ -515,7 +543,7 @@ public void apply(@NotNull Project project) { downloadTargetMappingsJar.flatMap(DownloadTargetMappingJarTask::getTargetJar) ); task.getExtractionDest().convention(task.provideVersionedProjectDir(version -> - Path.of(MappingsPlugin.TARGET_MAPPINGS_DIR, "quilt-mappings-" + version) + Path.of(QuiltMappingsPlugin.TARGET_MAPPINGS_DIR, "quilt-mappings-" + version) )); } ); @@ -523,9 +551,9 @@ public void apply(@NotNull Project project) { final var checkUnpickVersionsMatch = tasks.register( CheckUnpickVersionsMatchTask.TASK_NAME, CheckUnpickVersionsMatchTask.class, task -> { - task.getUnpickJson().convention( + task.getUnpickMeta().convention( extractTargetMappingsJar.flatMap(ExtractTargetMappingJarTask::getExtractionDest) - .map(dest -> dest.dir("extras").file("unpick.json")) + .map(dest -> dest.file(MappingsV2JarTask.JAR_UNPICK_META_PATH)) ); } ); @@ -546,12 +574,12 @@ public void apply(@NotNull Project project) { task -> { task.getInput().convention( extractTargetMappingsJar.flatMap(ExtractTargetMappingJarTask::getExtractionDest) - .map(dest -> dest.dir("extras").file("definitions.unpick")) + .map(dest -> dest.file(MappingsV2JarTask.JAR_UNPICK_DEFINITION_PATH)) ); task.getMappings().convention( extractTargetMappingsJar.flatMap(ExtractTargetMappingJarTask::getExtractionDest) - .map(dest -> dest.dir("mappings").file("mappings.tiny")) + .map(dest -> dest.file(MappingsV2JarTask.JAR_MAPPINGS_PATH)) ); task.getOutput().convention(task.provideVersionedProjectFile(version -> diff --git a/buildSrc/src/main/java/quilt/internal/tasks/EnigmaProfileConsumingTask.java b/buildSrc/src/main/java/quilt/internal/tasks/EnigmaProfileConsumingTask.java index 9b43e5db29..c609d3a858 100644 --- a/buildSrc/src/main/java/quilt/internal/tasks/EnigmaProfileConsumingTask.java +++ b/buildSrc/src/main/java/quilt/internal/tasks/EnigmaProfileConsumingTask.java @@ -7,6 +7,8 @@ import org.gradle.api.tasks.Internal; import org.quiltmc.enigma.api.EnigmaProfile; import org.quiltmc.enigma.api.service.JarIndexerService; +import quilt.internal.QuiltMappingsExtension; +import quilt.internal.QuiltMappingsPlugin; import java.util.Collection; import java.util.stream.Stream; @@ -16,9 +18,9 @@ /** * A task that takes an {@link EnigmaProfile} as input. *

- * If {@link quilt.internal.MappingsPlugin MappingsPlugin} is applied, any {@code EnigmaProfileConsumingTask}s will use - * {@link quilt.internal.MappingsExtension MappingsExtension}'s - * {@link quilt.internal.MappingsExtension#enigmaProfile enigmaProfile} by default. + * If {@link QuiltMappingsPlugin MappingsPlugin} is applied, any {@code EnigmaProfileConsumingTask}s will use + * {@link QuiltMappingsExtension MappingsExtension}'s + * {@link QuiltMappingsExtension#enigmaProfile enigmaProfile} by default. */ public abstract class EnigmaProfileConsumingTask extends DefaultMappingsTask { @Internal( diff --git a/buildSrc/src/main/java/quilt/internal/tasks/MappingsTask.java b/buildSrc/src/main/java/quilt/internal/tasks/MappingsTask.java index 66eb32858d..26ab0bca22 100644 --- a/buildSrc/src/main/java/quilt/internal/tasks/MappingsTask.java +++ b/buildSrc/src/main/java/quilt/internal/tasks/MappingsTask.java @@ -6,7 +6,7 @@ import org.gradle.api.file.Directory; import org.gradle.api.file.RegularFile; import org.gradle.api.provider.Provider; -import quilt.internal.MappingsExtension; +import quilt.internal.QuiltMappingsExtension; import quilt.internal.util.DownloadImmediate; // TODO check if tasks that depend on other other tasks' outputs have task dependencies that can be eliminated @@ -41,8 +41,8 @@ default void outputsNeverUpToDate() { this.getOutputs().upToDateWhen(task -> false); } - default MappingsExtension mappingsExt() { - return MappingsExtension.get(this.getProject()); + default QuiltMappingsExtension mappingsExt() { + return QuiltMappingsExtension.get(this.getProject()); } default VersionCatalogsExtension versionCatalogs() { diff --git a/buildSrc/src/main/java/quilt/internal/tasks/build/InvertPerVersionMappingsTask.java b/buildSrc/src/main/java/quilt/internal/tasks/build/InvertPerVersionMappingsTask.java index 4c14f3fead..183eaa12ec 100644 --- a/buildSrc/src/main/java/quilt/internal/tasks/build/InvertPerVersionMappingsTask.java +++ b/buildSrc/src/main/java/quilt/internal/tasks/build/InvertPerVersionMappingsTask.java @@ -8,9 +8,8 @@ import org.gradle.api.tasks.TaskAction; import org.jetbrains.annotations.VisibleForTesting; import quilt.internal.Constants; -import quilt.internal.MappingsPlugin; +import quilt.internal.QuiltMappingsPlugin; import quilt.internal.tasks.DefaultMappingsTask; -import quilt.internal.tasks.setup.DownloadMappingsTask; import quilt.internal.tasks.setup.ExtractTinyMappingsTask; import net.fabricmc.stitch.commands.tinyv2.CommandReorderTinyV2; @@ -26,7 +25,7 @@ public abstract class InvertPerVersionMappingsTask extends DefaultMappingsTask { public InvertPerVersionMappingsTask() { super(Constants.Groups.BUILD_MAPPINGS_GROUP); - this.dependsOn(MappingsPlugin.DOWNLOAD_PER_VERSION_MAPPINGS_TASK_NAME); + this.dependsOn(QuiltMappingsPlugin.DOWNLOAD_PER_VERSION_MAPPINGS_TASK_NAME); this.getInvertedTinyFile().convention(() -> new File( this.fileConstants.cacheFilesMinecraft, @@ -34,7 +33,7 @@ public InvertPerVersionMappingsTask() { )); this.getInput().convention( - this.getTaskNamed(MappingsPlugin.EXTRACT_TINY_PER_VERSION_MAPPINGS_TASK_NAME, ExtractTinyMappingsTask.class) + this.getTaskNamed(QuiltMappingsPlugin.EXTRACT_TINY_PER_VERSION_MAPPINGS_TASK_NAME, ExtractTinyMappingsTask.class) .getTinyFile() ); } diff --git a/buildSrc/src/main/java/quilt/internal/tasks/build/MappingsV2JarTask.java b/buildSrc/src/main/java/quilt/internal/tasks/build/MappingsV2JarTask.java index 3f1d002f09..5fb132a4d5 100644 --- a/buildSrc/src/main/java/quilt/internal/tasks/build/MappingsV2JarTask.java +++ b/buildSrc/src/main/java/quilt/internal/tasks/build/MappingsV2JarTask.java @@ -1,47 +1,77 @@ package quilt.internal.tasks.build; -import java.io.File; import java.util.Map; +import org.gradle.api.GradleException; import org.gradle.api.artifacts.VersionConstraint; +import org.gradle.api.file.RegularFile; import org.gradle.api.file.RegularFileProperty; +import org.gradle.api.provider.Provider; import org.gradle.api.tasks.InputFile; import org.gradle.jvm.tasks.Jar; import quilt.internal.Constants; import quilt.internal.tasks.MappingsTask; -import quilt.internal.tasks.unpick.CombineUnpickDefinitionsTask; +/** + * TODO is this an accurate description?
+ * A task that creates a jar file with Quilt's v2 mapping format. + *

+ * If {@link quilt.internal.QuiltMappingsPlugin QuiltMappingsPlugin} is applied: + *

    + *
  • + * {@link #getUnpickMeta() unpickMeta} will default to + * {@link quilt.internal.QuiltMappingsExtension QuiltMappingsExtension}'s + * {@link quilt.internal.QuiltMappingsExtension#getUnpickMeta() unpickMeta} + *
  • + * {@link #getUnpickDefinition() unpickDefinition} will default to + * {@value quilt.internal.tasks.unpick.CombineUnpickDefinitionsTask#TASK_NAME}'s + * {@link quilt.internal.tasks.unpick.CombineUnpickDefinitionsTask#getOutput() output} + *
  • + * {@link #getDestinationDirectory() destinationDirectory} will default to + * {@code libs/} inside the project build directory + *
+ * + */ public abstract class MappingsV2JarTask extends Jar implements MappingsTask { + public static final String JAR_UNPICK_META_PATH = "extras/unpick.json"; + public static final String JAR_UNPICK_DEFINITION_PATH = "extras/definitions.unpick"; + public static final String JAR_MAPPINGS_PATH = "mappings/mappings.tiny"; + + @InputFile + public abstract RegularFileProperty getUnpickMeta(); + + @InputFile + public abstract RegularFileProperty getUnpickDefinition(); + @InputFile public abstract RegularFileProperty getMappings(); public MappingsV2JarTask() { this.setGroup(Constants.Groups.BUILD_MAPPINGS_GROUP); + // TODO why? this.outputsNeverUpToDate(); - this.getDestinationDirectory().set(this.getProject().file("build/libs")); - // TODO make this an input - final File unpickMetaFile = this.mappingsExt().getUnpick().get().getAsFile(); - final String version = this.libs().findVersion("unpick").map(VersionConstraint::getRequiredVersion) - .orElseThrow(() -> new RuntimeException("Could not find unpick version")); + final String version = this.libs().findVersion("unpick") + .map(VersionConstraint::getRequiredVersion) + // provide an informative error message if no version is specified + .orElseThrow(() -> new GradleException( + """ + Could not find unpick version. + \tIn order to use any MappingsV2JarTask, an "unpick" version must be specified in the 'libs' \ + version catalog (usually by adding it to 'gradle/libs.versions.toml').\ + """ + )); + + final Provider unpickMeta = this.getUnpickMeta(); - this.from(unpickMetaFile, copySpec -> { + this.from(unpickMeta, copySpec -> { copySpec.expand(Map.of("version", version)); - copySpec.rename(unpickMetaFile.getName(), "extras/unpick.json"); + + copySpec.rename(unused -> JAR_UNPICK_META_PATH); }); - // TODO move this to a configureEach in MappingsPlugin - final RegularFileProperty combineUnpickDefinitions = - this.getTaskNamed(CombineUnpickDefinitionsTask.TASK_NAME, CombineUnpickDefinitionsTask.class).getOutput(); - this.from(combineUnpickDefinitions, copySpec -> - copySpec.rename( - combineUnpickDefinitions.get().getAsFile().getName(), - "extras/definitions.unpick" - ) - ); - - this.from(this.getMappings(), copySpec -> - copySpec.rename((originalName) -> "mappings/mappings.tiny") - ); + this.from(this.getUnpickDefinition(), copySpec -> copySpec.rename(unused -> JAR_UNPICK_DEFINITION_PATH)); + + this.from(this.getMappings(), copySpec -> copySpec.rename(unused -> JAR_MAPPINGS_PATH)); } } diff --git a/buildSrc/src/main/java/quilt/internal/tasks/diff/CheckTargetVersionExistsTask.java b/buildSrc/src/main/java/quilt/internal/tasks/diff/CheckTargetVersionExistsTask.java index 226d9cc39f..f8d2cad0e7 100644 --- a/buildSrc/src/main/java/quilt/internal/tasks/diff/CheckTargetVersionExistsTask.java +++ b/buildSrc/src/main/java/quilt/internal/tasks/diff/CheckTargetVersionExistsTask.java @@ -72,7 +72,7 @@ public void checkExists() { /** * This is only populated after the task has run. *

- * It should only be accessed from other tasks' {@linkplain TaskAction actions} or + * It should only be accessed from other tasks' {@linkplain TaskAction actions} or * {@linkplain org.gradle.api.Task#onlyIf predicates} and via * {@linkplain Property lazy} {@linkplain org.gradle.api.tasks.Input input}. *

diff --git a/buildSrc/src/main/java/quilt/internal/tasks/diff/CheckUnpickVersionsMatchTask.java b/buildSrc/src/main/java/quilt/internal/tasks/diff/CheckUnpickVersionsMatchTask.java index 72755c0186..b023090ecf 100644 --- a/buildSrc/src/main/java/quilt/internal/tasks/diff/CheckUnpickVersionsMatchTask.java +++ b/buildSrc/src/main/java/quilt/internal/tasks/diff/CheckUnpickVersionsMatchTask.java @@ -23,7 +23,7 @@ public abstract class CheckUnpickVersionsMatchTask extends DefaultMappingsTask i public static final String TASK_NAME = "checkUnpickVersionsMatch"; @InputFile - public abstract RegularFileProperty getUnpickJson(); + public abstract RegularFileProperty getUnpickMeta(); @Internal protected abstract Property getMatch(); @@ -43,7 +43,7 @@ public CheckUnpickVersionsMatchTask() { @TaskAction public void checkMatch() throws IOException { - final JsonElement parsed = JsonParser.parseReader(new FileReader(this.getUnpickJson().getAsFile().get())); + final JsonElement parsed = JsonParser.parseReader(new FileReader(this.getUnpickMeta().getAsFile().get())); this.getMatch().set( parsed.getAsJsonObject().get("unpickVersion").getAsString().equals( this.libs().findVersion("unpick").map(VersionConstraint::getRequiredVersion).orElse("") @@ -54,7 +54,7 @@ public void checkMatch() throws IOException { /** * This is only populated after the task has run. *

- * It should only be accessed from other tasks' {@linkplain TaskAction actions} or + * It should only be accessed from other tasks' {@linkplain TaskAction actions} or * {@linkplain org.gradle.api.Task#onlyIf predicates} and via * {@linkplain Property lazy} {@linkplain org.gradle.api.tasks.Input input}. *

diff --git a/buildSrc/src/main/java/quilt/internal/tasks/diff/TargetVersionConsumingTask.java b/buildSrc/src/main/java/quilt/internal/tasks/diff/TargetVersionConsumingTask.java index 97b3c0fe1e..e78171ebf1 100644 --- a/buildSrc/src/main/java/quilt/internal/tasks/diff/TargetVersionConsumingTask.java +++ b/buildSrc/src/main/java/quilt/internal/tasks/diff/TargetVersionConsumingTask.java @@ -7,6 +7,7 @@ import org.gradle.api.provider.Provider; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Optional; +import quilt.internal.QuiltMappingsPlugin; import quilt.internal.tasks.MappingsTask; import java.io.File; @@ -17,7 +18,7 @@ *

* A target version is a published Quilt Mappings version obtained from the Quilt maven. *

- * If {@link quilt.internal.MappingsPlugin MappingsPlugin} is applied, any {@code TargetVersionConsumingTask}s + * If {@link QuiltMappingsPlugin MappingsPlugin} is applied, any {@code TargetVersionConsumingTask}s * will use {@value CheckTargetVersionExistsTask#TASK_NAME}'s * {@link CheckTargetVersionExistsTask#getTargetVersion() targetVersion} by default, and they'll only run if the * {@link #getTargetVersion() targetVersion} {@link Provider#isPresent() isPresent}. diff --git a/buildSrc/src/main/java/quilt/internal/tasks/diff/UnpickVersionsMatchConsumingTask.java b/buildSrc/src/main/java/quilt/internal/tasks/diff/UnpickVersionsMatchConsumingTask.java index 700064ba18..1983d07857 100644 --- a/buildSrc/src/main/java/quilt/internal/tasks/diff/UnpickVersionsMatchConsumingTask.java +++ b/buildSrc/src/main/java/quilt/internal/tasks/diff/UnpickVersionsMatchConsumingTask.java @@ -4,11 +4,12 @@ import org.gradle.api.provider.Provider; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Optional; +import quilt.internal.QuiltMappingsPlugin; /** * A task that takes whether two unpick versions match as input. *

- * If {@link quilt.internal.MappingsPlugin MappingsPlugin} is applied, any {@code UnpickVersionsMatchConsumingTask}s + * If {@link QuiltMappingsPlugin MappingsPlugin} is applied, any {@code UnpickVersionsMatchConsumingTask}s * will use {@value CheckUnpickVersionsMatchTask#TASK_NAME}'s * {@link CheckUnpickVersionsMatchTask#isMatch() match} by default, and they'll only run if * {@link #getUnpickVersionsMatch() unpickVersionsMatch} {@link Provider#isPresent() isPresent} and {@code true}. diff --git a/buildSrc/src/main/java/quilt/internal/tasks/setup/DownloadMinecraftLibrariesTask.java b/buildSrc/src/main/java/quilt/internal/tasks/setup/DownloadMinecraftLibrariesTask.java index ba95102d65..e907f64dab 100644 --- a/buildSrc/src/main/java/quilt/internal/tasks/setup/DownloadMinecraftLibrariesTask.java +++ b/buildSrc/src/main/java/quilt/internal/tasks/setup/DownloadMinecraftLibrariesTask.java @@ -132,7 +132,7 @@ public void downloadMinecraftLibrariesTask() { /** * This is only populated after the task has run. *

- * It should only be accessed from other tasks' {@linkplain TaskAction actions} and via + * It should only be accessed from other tasks' {@linkplain TaskAction actions} and via * {@linkplain MapProperty lazy} {@linkplain org.gradle.api.tasks.Input input}. */ @Internal diff --git a/buildSrc/src/main/java/quilt/internal/tasks/unpick/CombineUnpickDefinitionsTask.java b/buildSrc/src/main/java/quilt/internal/tasks/unpick/CombineUnpickDefinitionsTask.java index f106f11020..1289056227 100644 --- a/buildSrc/src/main/java/quilt/internal/tasks/unpick/CombineUnpickDefinitionsTask.java +++ b/buildSrc/src/main/java/quilt/internal/tasks/unpick/CombineUnpickDefinitionsTask.java @@ -2,15 +2,12 @@ import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.UncheckedIOException; import java.nio.file.Files; import java.nio.file.Path; -import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; -import java.util.List; import java.util.Set; import daomephsta.unpick.constantmappers.datadriven.parser.v2.UnpickV2Reader; @@ -25,17 +22,17 @@ import org.gradle.api.tasks.TaskAction; import org.gradle.workers.WorkAction; import org.gradle.workers.WorkParameters; -import org.gradle.workers.WorkQueue; import org.gradle.workers.WorkerExecutor; import org.jetbrains.annotations.VisibleForTesting; import quilt.internal.Constants; +import quilt.internal.QuiltMappingsPlugin; import quilt.internal.tasks.DefaultMappingsTask; import quilt.internal.util.UnpickUtil; /** * Combines many unpick definition files into one new file. *

- * If {@link quilt.internal.MappingsPlugin} is applied, the + * If {@link QuiltMappingsPlugin} is applied, the * {@linkplain quilt.internal.tasks.unpick.gen.UnpickGenTask#getGeneratedUnpickDefinitions() generated definitions} * from all {@link quilt.internal.tasks.unpick.gen.UnpickGenTask UnpickGenTask}s will be amongst those combined. */ diff --git a/enigma_profile.json b/enigma/enigma_profile.json similarity index 100% rename from enigma_profile.json rename to enigma/enigma_profile.json diff --git a/simple_type_field_names.json5 b/enigma/simple_type_field_names.json5 similarity index 100% rename from simple_type_field_names.json5 rename to enigma/simple_type_field_names.json5