Skip to content

Commit

Permalink
rename MappingsPlugin -> QuiltMappingsPlugin and its id mappings-logi…
Browse files Browse the repository at this point in the history
…c -> quilt-mappings

rename MappingsExtension -> QuiltMappingsExtension and its name mappings -> quiltMappings
move enimga_profile.json and simple_type_field_names.json5 to enigma/
rename some things in MappingsExtension
refine MappingsV2JarTask's properties, extract some magic constants, and move some configuration to a configureEach in QuiltMappingsPlugin
  • Loading branch information
supersaiyansubtlety committed Oct 7, 2024
1 parent ce95c5a commit 8f84a8f
Show file tree
Hide file tree
Showing 16 changed files with 167 additions and 113 deletions.
34 changes: 14 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import quilt.internal.tasks.build.MappingsV2JarTask

buildscript {
repositories {
maven {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -161,31 +163,23 @@ 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) {
jarToMap.set unpickHashedJar.outputFile.get()
}

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)
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -350,7 +344,7 @@ generatePackageInfoMappings {
mappingLint {
dependsOn mapPerVersionMappingsJar
mappingDirectory = file("mappings")
jarFile = mappings.fileConstants.perVersionMappingsJar
jarFile = quiltMappings.fileConstants.perVersionMappingsJar
}

check.dependsOn mappingLint
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ test {

gradlePlugin {
plugins {
mappingsLogic {
id = 'mappings-logic'
implementationClass = 'quilt.internal.MappingsPlugin'
quiltMappings {
id = 'quilt-mappings'
implementationClass = 'quilt.internal.QuiltMappingsPlugin'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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> 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 -> {
Expand All @@ -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<? extends RegularFile> fileProvider) {
this.getEnigmaProfileFile().set(fileProvider);
public void setEnigmaProfileConfig(Provider<? extends RegularFile> fileProvider) {
this.getEnigmaProfileConfigImpl().set(fileProvider);
}
}
Loading

0 comments on commit 8f84a8f

Please sign in to comment.