Initial work on remapping mixins

dev/0.11
modmuss50 2016-09-28 16:51:31 +01:00
parent c322cbd3de
commit 5e18df32a5
3 changed files with 33 additions and 2 deletions

View File

@ -15,7 +15,7 @@ apply from: 'https://github.com/FabricMC/fabric-docs/raw/master/gradle/license.g
group = 'net.fabricmc' group = 'net.fabricmc'
archivesBaseName = project.name.toLowerCase() archivesBaseName = project.name.toLowerCase()
version = '0.0.3-SNAPSHOT' version = '0.0.4-SNAPSHOT'
repositories { repositories {
mavenCentral() mavenCentral()

View File

@ -31,6 +31,7 @@ import com.google.gson.JsonObject;
import net.fabricmc.loom.task.DownloadTask; import net.fabricmc.loom.task.DownloadTask;
import net.fabricmc.loom.util.Constants; import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.Version; import net.fabricmc.loom.util.Version;
import org.gradle.api.Action;
import org.gradle.api.Plugin; import org.gradle.api.Plugin;
import org.gradle.api.Project; import org.gradle.api.Project;
import org.gradle.api.Task; import org.gradle.api.Task;
@ -38,6 +39,7 @@ import org.gradle.api.artifacts.repositories.MavenArtifactRepository;
import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention; import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.compile.JavaCompile;
import org.gradle.api.tasks.javadoc.Javadoc; import org.gradle.api.tasks.javadoc.Javadoc;
import org.gradle.plugins.ide.eclipse.model.EclipseModel; import org.gradle.plugins.ide.eclipse.model.EclipseModel;
import org.gradle.plugins.ide.idea.model.IdeaModel; import org.gradle.plugins.ide.idea.model.IdeaModel;
@ -46,6 +48,8 @@ import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.util.Map;
import java.util.Set;
public class AbstractPlugin implements Plugin<Project> { public class AbstractPlugin implements Plugin<Project> {
protected Project project; protected Project project;
@ -62,7 +66,8 @@ public class AbstractPlugin implements Plugin<Project> {
project.getExtensions().create("minecraft", LoomGradleExtension.class); project.getExtensions().create("minecraft", LoomGradleExtension.class);
project.getExtensions().getByType(LoomGradleExtension.class).project = project; project.getExtensions().getByType(LoomGradleExtension.class).project = project;
readModJson(project.getExtensions().getByType(LoomGradleExtension.class)); LoomGradleExtension extension = project.getExtensions().getByType(LoomGradleExtension.class);
readModJson(extension);
// Force add Mojang repository // Force add Mojang repository
addMavenRepo(target, "Mojang", "https://libraries.minecraft.net/"); addMavenRepo(target, "Mojang", "https://libraries.minecraft.net/");
@ -77,6 +82,29 @@ public class AbstractPlugin implements Plugin<Project> {
configureIDEs(); configureIDEs();
configureCompile(); configureCompile();
//TODO other languages?
Map<Project,Set<Task>> taskMap = project.getAllTasks(true);
for(Map.Entry<Project,Set<Task>> entry : taskMap.entrySet()) {
Project project = entry.getKey();
Set<Task> taskSet = entry.getValue();
for(Task task : taskSet){
if(task instanceof JavaCompile){
JavaCompile javaCompileTask = (JavaCompile) task;
javaCompileTask.doFirst(task1 -> {
project.getLogger().lifecycle(":setting java compiler args");
try {
javaCompileTask.getOptions().getCompilerArgs().add("-AreobfNotchSrgFile=" + Constants.MAPPINGS_SRG.get(extension).getCanonicalPath());
javaCompileTask.getOptions().getCompilerArgs().add("-AdefaultObfuscationEnv=notch");
} catch (IOException e) {
e.printStackTrace();
}
});
}
}
}
} }
/** /**

View File

@ -46,6 +46,9 @@ public class Constants {
public static final IDelayed<File> POMF_DIR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), "pomf")); public static final IDelayed<File> POMF_DIR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), "pomf"));
public static final IDelayed<File> MAPPINGS_ZIP = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip")); public static final IDelayed<File> MAPPINGS_ZIP = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + ".zip"));
public static final IDelayed<File> MAPPINGS_DIR = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + "")); public static final IDelayed<File> MAPPINGS_DIR = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomfVersion + ""));
public static final IDelayed<File> MAPPINGS_SRG = new DelayedFile(extension -> new File(WORKING_DIRECTORY, "mappings.srg"));
public static final IDelayed<File> REF_MAP = new DelayedFile(extension -> new File(WORKING_DIRECTORY, "RefMap.json"));
public static final IDelayed<File> MINECRAFT_LIBS = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-libs")); public static final IDelayed<File> MINECRAFT_LIBS = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-libs"));
public static final IDelayed<File> MINECRAFT_NATIVES = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-natives")); public static final IDelayed<File> MINECRAFT_NATIVES = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-natives"));