aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net/fabricmc/loom/api/mappings
diff options
context:
space:
mode:
authormodmuss50 <modmuss50@gmail.com>2021-11-20 21:46:33 +0000
committerGitHub <noreply@github.com>2021-11-20 21:46:33 +0000
commitbabbc555869c0a9cba90cbcac7dcba241ee62099 (patch)
tree0f0eddb38134183ff12c32b4e28a475a6d19c45d /src/main/java/net/fabricmc/loom/api/mappings
parent9c2b1e8d6ddd3ac97a67343100fc7a9c35b7c625 (diff)
downloadarchitectury-loom-babbc555869c0a9cba90cbcac7dcba241ee62099.tar.gz
architectury-loom-babbc555869c0a9cba90cbcac7dcba241ee62099.tar.bz2
architectury-loom-babbc555869c0a9cba90cbcac7dcba241ee62099.zip
Add an option (enabled by default) to map synthetic field and method names from the official mojang mappings. (#538)
Diffstat (limited to 'src/main/java/net/fabricmc/loom/api/mappings')
-rw-r--r--src/main/java/net/fabricmc/loom/api/mappings/layered/spec/LayeredMappingSpecBuilder.java27
-rw-r--r--src/main/java/net/fabricmc/loom/api/mappings/layered/spec/MojangMappingsSpecBuilder.java36
2 files changed, 61 insertions, 2 deletions
diff --git a/src/main/java/net/fabricmc/loom/api/mappings/layered/spec/LayeredMappingSpecBuilder.java b/src/main/java/net/fabricmc/loom/api/mappings/layered/spec/LayeredMappingSpecBuilder.java
index fd16f23c..1ed527e0 100644
--- a/src/main/java/net/fabricmc/loom/api/mappings/layered/spec/LayeredMappingSpecBuilder.java
+++ b/src/main/java/net/fabricmc/loom/api/mappings/layered/spec/LayeredMappingSpecBuilder.java
@@ -24,7 +24,10 @@
package net.fabricmc.loom.api.mappings.layered.spec;
+import groovy.lang.Closure;
+import groovy.lang.DelegatesTo;
import org.gradle.api.Action;
+import org.gradle.util.ConfigureUtil;
import org.jetbrains.annotations.ApiStatus;
/**
@@ -38,14 +41,34 @@ public interface LayeredMappingSpecBuilder {
LayeredMappingSpecBuilder addLayer(MappingsSpec<?> mappingSpec);
/**
- * Add a layer that uses the official mappings provided by Mojang.
+ * Add a layer that uses the official mappings provided by Mojang with the default options.
*/
- LayeredMappingSpecBuilder officialMojangMappings();
+ default LayeredMappingSpecBuilder officialMojangMappings() {
+ return officialMojangMappings(builder -> { });
+ }
+
+ /**
+ * Configure and add a layer that uses the official mappings provided by Mojang.
+ */
+ @SuppressWarnings("rawtypes")
+ default LayeredMappingSpecBuilder officialMojangMappings(@DelegatesTo(value = MojangMappingsSpecBuilder.class, strategy = Closure.DELEGATE_FIRST) Closure closure) {
+ return officialMojangMappings(mojangMappingsSpecBuilder -> ConfigureUtil.configure(closure, mojangMappingsSpecBuilder));
+ }
+
+ /**
+ * Configure and add a layer that uses the official mappings provided by Mojang.
+ */
+ LayeredMappingSpecBuilder officialMojangMappings(Action<MojangMappingsSpecBuilder> action);
default LayeredMappingSpecBuilder parchment(Object object) {
return parchment(object, parchmentMappingsSpecBuilder -> parchmentMappingsSpecBuilder.setRemovePrefix(true));
}
+ @SuppressWarnings("rawtypes")
+ default LayeredMappingSpecBuilder parchment(Object object, @DelegatesTo(value = ParchmentMappingsSpecBuilder.class, strategy = Closure.DELEGATE_FIRST) Closure closure) {
+ return parchment(object, parchmentMappingsSpecBuilder -> ConfigureUtil.configure(closure, parchmentMappingsSpecBuilder));
+ }
+
LayeredMappingSpecBuilder parchment(Object object, Action<ParchmentMappingsSpecBuilder> action);
/**
diff --git a/src/main/java/net/fabricmc/loom/api/mappings/layered/spec/MojangMappingsSpecBuilder.java b/src/main/java/net/fabricmc/loom/api/mappings/layered/spec/MojangMappingsSpecBuilder.java
new file mode 100644
index 00000000..1db0ff02
--- /dev/null
+++ b/src/main/java/net/fabricmc/loom/api/mappings/layered/spec/MojangMappingsSpecBuilder.java
@@ -0,0 +1,36 @@
+/*
+ * This file is part of fabric-loom, licensed under the MIT License (MIT).
+ *
+ * Copyright (c) 2021 FabricMC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package net.fabricmc.loom.api.mappings.layered.spec;
+
+public interface MojangMappingsSpecBuilder {
+ /**
+ * When enabled synthetic fields and methods will be mapped to name specified in the official mojang mappings.
+ *
+ * <p>When disabled synthetic fields and methods will not be mapped leaving them with their intermediary name.
+ */
+ MojangMappingsSpecBuilder setNameSyntheticMembers(boolean value);
+
+ boolean getNameSyntheticMembers();
+}