mirror of
https://github.com/architectury/architectury-loom.git
synced 2026-03-30 05:05:20 -05:00
Add srgRemapJar (unknown if it works, I need to add more Forge dependencies first)
This commit is contained in:
@@ -21,7 +21,7 @@ if (ENV.BUILD_NUMBER) {
|
||||
build = 'jenkins #${ENV.BUILD_NUMBER}'
|
||||
version = baseVersion + '.' + ENV.BUILD_NUMBER
|
||||
} else {
|
||||
version = baseVersion + '-forge.27'
|
||||
version = baseVersion + '-forge.28'
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -61,6 +61,7 @@ import net.fabricmc.loom.task.AbstractLoomTask;
|
||||
import net.fabricmc.loom.task.RemapAllSourcesTask;
|
||||
import net.fabricmc.loom.task.RemapJarTask;
|
||||
import net.fabricmc.loom.task.RemapSourcesJarTask;
|
||||
import net.fabricmc.loom.task.SrgRemapJarTask;
|
||||
import net.fabricmc.loom.util.Constants;
|
||||
import net.fabricmc.loom.util.DownloadUtil;
|
||||
import net.fabricmc.loom.util.FabricApiExtension;
|
||||
@@ -266,13 +267,18 @@ public class AbstractPlugin implements Plugin<Project> {
|
||||
if (extension.remapMod) {
|
||||
AbstractArchiveTask jarTask = (AbstractArchiveTask) project1.getTasks().getByName("jar");
|
||||
RemapJarTask remapJarTask = (RemapJarTask) project1.getTasks().findByName("remapJar");
|
||||
SrgRemapJarTask srgRemapJarTask = (SrgRemapJarTask) project1.getTasks().findByName("srgRemapJar");
|
||||
|
||||
assert remapJarTask != null;
|
||||
assert srgRemapJarTask != null;
|
||||
|
||||
if (!remapJarTask.getInput().isPresent()) {
|
||||
jarTask.setClassifier("dev");
|
||||
remapJarTask.setClassifier("");
|
||||
remapJarTask.setClassifier("official");
|
||||
remapJarTask.getInput().set(jarTask.getArchivePath());
|
||||
srgRemapJarTask.setClassifier("");
|
||||
srgRemapJarTask.getInput().set(remapJarTask.getArchivePath());
|
||||
srgRemapJarTask.getMappings().set(extension.getMcpConfigProvider().getSrg());
|
||||
}
|
||||
|
||||
extension.getUnmappedModCollection().from(jarTask);
|
||||
@@ -280,8 +286,10 @@ public class AbstractPlugin implements Plugin<Project> {
|
||||
remapJarTask.getRemapAccessWidener().set(true);
|
||||
|
||||
project1.getArtifacts().add("archives", remapJarTask);
|
||||
project1.getArtifacts().add("archives", srgRemapJarTask);
|
||||
remapJarTask.dependsOn(jarTask);
|
||||
project1.getTasks().getByName("build").dependsOn(remapJarTask);
|
||||
project1.getTasks().getByName("build").dependsOn(srgRemapJarTask);
|
||||
|
||||
Map<Project, Set<Task>> taskMap = project.getAllTasks(true);
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ import net.fabricmc.loom.task.RemapJarTask;
|
||||
import net.fabricmc.loom.task.RemapSourcesJarTask;
|
||||
import net.fabricmc.loom.task.RunClientTask;
|
||||
import net.fabricmc.loom.task.RunServerTask;
|
||||
import net.fabricmc.loom.task.SrgRemapJarTask;
|
||||
|
||||
public class LoomGradlePlugin extends AbstractPlugin {
|
||||
public static File getMappedByproduct(Project project, String suffix) {
|
||||
@@ -88,6 +89,12 @@ public class LoomGradlePlugin extends AbstractPlugin {
|
||||
t.setGroup("fabric");
|
||||
});
|
||||
|
||||
tasks.register("srgRemapJar", SrgRemapJarTask.class, t -> {
|
||||
t.setDescription("Remaps the built project jar to intermediary mappings.");
|
||||
t.setGroup("fabric");
|
||||
t.dependsOn("remapJar");
|
||||
});
|
||||
|
||||
tasks.register("downloadAssets", DownloadAssetsTask.class, t -> t.setDescription("Downloads required assets for Fabric."));
|
||||
|
||||
tasks.register("genIdeaWorkspace", GenIdeaProjectTask.class, t -> {
|
||||
|
||||
@@ -91,7 +91,8 @@ public class RemapJarTask extends Jar {
|
||||
MappingsProvider mappingsProvider = extension.getMappingsProvider();
|
||||
|
||||
String fromM = "named";
|
||||
String toM = "intermediary";
|
||||
String toM = "official";
|
||||
// ^ This is passed to SrgRemapJarTask.
|
||||
|
||||
Set<File> classpathFiles = new LinkedHashSet<>(
|
||||
project.getConfigurations().getByName("compileClasspath").getFiles()
|
||||
|
||||
81
src/main/java/net/fabricmc/loom/task/SrgRemapJarTask.java
Normal file
81
src/main/java/net/fabricmc/loom/task/SrgRemapJarTask.java
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* This file is part of fabric-loom, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2016, 2017, 2018 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.task;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
|
||||
import org.cadixdev.atlas.Atlas;
|
||||
import org.cadixdev.bombe.asm.jar.JarEntryRemappingTransformer;
|
||||
import org.cadixdev.lorenz.MappingSet;
|
||||
import org.cadixdev.lorenz.asm.LorenzRemapper;
|
||||
import org.cadixdev.lorenz.io.srg.tsrg.TSrgReader;
|
||||
import org.gradle.api.file.RegularFileProperty;
|
||||
import org.gradle.api.tasks.InputFile;
|
||||
import org.gradle.api.tasks.OutputFile;
|
||||
import org.gradle.api.tasks.TaskAction;
|
||||
import org.gradle.jvm.tasks.Jar;
|
||||
|
||||
import net.fabricmc.loom.util.GradleSupport;
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class SrgRemapJarTask extends Jar {
|
||||
private final RegularFileProperty input;
|
||||
private final RegularFileProperty mappings;
|
||||
|
||||
public SrgRemapJarTask() {
|
||||
super();
|
||||
input = GradleSupport.getfileProperty(getProject());
|
||||
mappings = GradleSupport.getfileProperty(getProject());
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
public void doTask() throws Throwable {
|
||||
try (TSrgReader reader = new TSrgReader(new FileReader(mappings.getAsFile().get()));
|
||||
Atlas atlas = new Atlas()) {
|
||||
MappingSet mappings = reader.read();
|
||||
|
||||
atlas.install(ctx -> new JarEntryRemappingTransformer(
|
||||
new LorenzRemapper(mappings, ctx.inheritanceProvider())
|
||||
));
|
||||
|
||||
for (File file : getProject().getConfigurations().getByName("runtimeClasspath")) {
|
||||
atlas.use(file.toPath());
|
||||
}
|
||||
|
||||
atlas.run(input.getAsFile().get().toPath(), getArchivePath().toPath());
|
||||
}
|
||||
}
|
||||
|
||||
@InputFile
|
||||
public RegularFileProperty getInput() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@InputFile
|
||||
public RegularFileProperty getMappings() {
|
||||
return mappings;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user