Initial work on pre baking mixins

Downloading of fabric base + deps needs fixing, I may do it a different way.

This is mainly moving pc commit as a lot of stuff here isn't final.
dev/0.11
modmuss50 2016-10-07 13:17:04 +01:00
parent 5e18df32a5
commit 3f24ce0289
No known key found for this signature in database
GPG Key ID: 203A5ED4D3E48BEA
11 changed files with 172 additions and 18 deletions

View File

@ -31,6 +31,14 @@ repositories {
name "RX14 Repository" name "RX14 Repository"
url 'http://mvn.rx14.co.uk/local/' url 'http://mvn.rx14.co.uk/local/'
} }
maven {
name = 'Mojang'
url = 'https://libraries.minecraft.net/'
}
maven {
name = 'SpongePowered'
url = 'http://repo.spongepowered.org/maven'
}
} }
configurations { configurations {
@ -50,6 +58,10 @@ dependencies {
shade 'com.google.guava:guava:19.0' shade 'com.google.guava:guava:19.0'
shade 'net.fabricmc:weave:0.1.0.6' shade 'net.fabricmc:weave:0.1.0.6'
shade 'cuchaz:enigma:0.11.0.5:lib' shade 'cuchaz:enigma:0.11.0.5:lib'
shade 'org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-depchain:2.2.4'
compile 'net.fabricmc:fabric-base:16w38a-0.0.4-SNAPSHOT'
} }
sourceSets { sourceSets {
@ -60,10 +72,8 @@ sourceSets {
} }
jar { jar {
configurations.shade.each { dep -> from {
from(project.zipTree(dep)) { configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
exclude 'META-INF', 'META-INF/**'
}
} }
} }

View File

@ -31,7 +31,6 @@ 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;
@ -76,6 +75,7 @@ public class AbstractPlugin implements Plugin<Project> {
project.getConfigurations().maybeCreate(Constants.CONFIG_MC_DEPENDENCIES); project.getConfigurations().maybeCreate(Constants.CONFIG_MC_DEPENDENCIES);
project.getConfigurations().maybeCreate(Constants.CONFIG_MC_DEPENDENCIES_CLIENT); project.getConfigurations().maybeCreate(Constants.CONFIG_MC_DEPENDENCIES_CLIENT);
project.getConfigurations().maybeCreate(Constants.CONFIG_NATIVES); project.getConfigurations().maybeCreate(Constants.CONFIG_NATIVES);
project.getConfigurations().maybeCreate(Constants.COMPILE_MODS);
// Common libraries extends from client libraries, CONFIG_MC_DEPENDENCIES will contains all MC dependencies // Common libraries extends from client libraries, CONFIG_MC_DEPENDENCIES will contains all MC dependencies
project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES).extendsFrom(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES_CLIENT)); project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES).extendsFrom(project.getConfigurations().getByName(Constants.CONFIG_MC_DEPENDENCIES_CLIENT));
@ -84,12 +84,12 @@ public class AbstractPlugin implements Plugin<Project> {
configureCompile(); configureCompile();
//TODO other languages? //TODO other languages?
Map<Project,Set<Task>> taskMap = project.getAllTasks(true); Map<Project, Set<Task>> taskMap = project.getAllTasks(true);
for(Map.Entry<Project,Set<Task>> entry : taskMap.entrySet()) { for (Map.Entry<Project, Set<Task>> entry : taskMap.entrySet()) {
Project project = entry.getKey(); Project project = entry.getKey();
Set<Task> taskSet = entry.getValue(); Set<Task> taskSet = entry.getValue();
for(Task task : taskSet){ for (Task task : taskSet) {
if(task instanceof JavaCompile){ if (task instanceof JavaCompile) {
JavaCompile javaCompileTask = (JavaCompile) task; JavaCompile javaCompileTask = (JavaCompile) task;
javaCompileTask.doFirst(task1 -> { javaCompileTask.doFirst(task1 -> {
project.getLogger().lifecycle(":setting java compiler args"); project.getLogger().lifecycle(":setting java compiler args");
@ -227,7 +227,7 @@ public class AbstractPlugin implements Plugin<Project> {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
project1.getDependencies().add(Constants.CONFIG_MC_DEPENDENCIES, "net.minecraft:" + Constants.MINECRAFT_MAPPED_JAR.get(extension).getName().replace(".jar", "")); project1.getDependencies().add(Constants.CONFIG_MC_DEPENDENCIES, "net.minecraft:" + Constants.MINECRAFT_FINAL_JAR.get(extension).getName().replace(".jar", ""));
if (extension.fabricVersion != null && !extension.fabricVersion.isEmpty()) { if (extension.fabricVersion != null && !extension.fabricVersion.isEmpty()) {
//only add this when not in a fabric dev env //only add this when not in a fabric dev env

View File

@ -36,7 +36,8 @@ public class LoomGradlePlugin extends AbstractPlugin {
makeTask("download", DownloadTask.class); makeTask("download", DownloadTask.class);
makeTask("mergeJars", MergeJarsTask.class).dependsOn("download"); makeTask("mergeJars", MergeJarsTask.class).dependsOn("download");
makeTask("mapJars", MapJarsTask.class).dependsOn("mergeJars"); makeTask("mapJars", MapJarsTask.class).dependsOn("mergeJars");
makeTask("setupFabric", DefaultTask.class).dependsOn("mapJars"); makeTask("processMods", ProcessModsTask.class).dependsOn("mapJars");
makeTask("setupFabric", DefaultTask.class).dependsOn("processMods");
makeTask("extractNatives", ExtractNativesTask.class).dependsOn("download"); makeTask("extractNatives", ExtractNativesTask.class).dependsOn("download");
makeTask("genIdeaRuns", GenIdeaProjectTask.class).dependsOn("cleanIdea").dependsOn("idea").dependsOn("extractNatives"); makeTask("genIdeaRuns", GenIdeaProjectTask.class).dependsOn("cleanIdea").dependsOn("idea").dependsOn("extractNatives");

View File

@ -45,7 +45,6 @@ import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.nio.charset.Charset;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;

View File

@ -35,7 +35,6 @@ import org.gradle.api.tasks.TaskAction;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -59,7 +58,7 @@ public class GenVSCodeProjectTask extends DefaultTask {
libs.add(library.getFile(extension).getAbsolutePath()); libs.add(library.getFile(extension).getAbsolutePath());
} }
} }
libs.add(Constants.MINECRAFT_MAPPED_JAR.get(extension).getAbsolutePath()); libs.add(Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath());
for (File file : getProject().getConfigurations().getByName("compile").getFiles()) { for (File file : getProject().getConfigurations().getByName("compile").getFiles()) {
libs.add(file.getAbsolutePath()); libs.add(file.getAbsolutePath());
} }

View File

@ -51,7 +51,6 @@ public class MapJarsTask extends DefaultTask {
@TaskAction @TaskAction
public void mapJars() throws IOException, MappingParseException { public void mapJars() throws IOException, MappingParseException {
LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class); LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class);
if (!Constants.MINECRAFT_MAPPED_JAR.get(extension).exists()) { if (!Constants.MINECRAFT_MAPPED_JAR.get(extension).exists()) {
this.getLogger().lifecycle(":unpacking mappings"); this.getLogger().lifecycle(":unpacking mappings");
if (!Constants.MAPPINGS_DIR.get(extension).exists()) { if (!Constants.MAPPINGS_DIR.get(extension).exists()) {
@ -76,6 +75,7 @@ public class MapJarsTask extends DefaultTask {
ZipUtil.pack(tempAssests, Constants.MINECRAFT_MAPPED_JAR.get(extension)); ZipUtil.pack(tempAssests, Constants.MINECRAFT_MAPPED_JAR.get(extension));
} else { } else {
this.getLogger().lifecycle(Constants.MINECRAFT_MAPPED_JAR.get(extension).getAbsolutePath());
this.getLogger().lifecycle(":mapped jar found, skipping mapping"); this.getLogger().lifecycle(":mapped jar found, skipping mapping");
} }
} }

View File

@ -0,0 +1,90 @@
/*
* This file is part of fabric-loom, licensed under the MIT License (MIT).
*
* Copyright (c) 2016 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 net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Constants;
import net.fabricmc.loom.util.proccessing.PreBakeMixins;
import org.apache.commons.io.FileUtils;
import org.gradle.api.DefaultTask;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.ResolvedArtifact;
import org.gradle.api.tasks.TaskAction;
import org.jboss.shrinkwrap.resolver.api.maven.ConfigurableMavenResolverSystem;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
public class ProcessModsTask extends DefaultTask {
@TaskAction
public void mix() throws InvocationTargetException, NoSuchMethodException, IllegalAccessException, IOException {
LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class);
Configuration configuration = getProject().getConfigurations().getByName(Constants.COMPILE_MODS);
List<File> mods = new ArrayList<>();
for (ResolvedArtifact artifact : configuration.getResolvedConfiguration().getResolvedArtifacts()) {
getProject().getLogger().lifecycle(":found mod to mix:" + artifact.getFile().getName());
mods.add(artifact.getFile());
}
if (Constants.MINECRAFT_FINAL_JAR.get(extension).exists()) {
Constants.MINECRAFT_FINAL_JAR.get(extension).delete();
}
if (mods.size() == 0) {
FileUtils.copyFile(Constants.MINECRAFT_MAPPED_JAR.get(extension), Constants.MINECRAFT_FINAL_JAR.get(extension));
} else {
//TODO figure out a way to specify what deps do what
//TODO download deps when needed
downloadRequiredDeps(extension);
new PreBakeMixins().proccess(getProject(), extension, mods);
}
}
public void downloadRequiredDeps(LoomGradleExtension extension) {
ConfigurableMavenResolverSystem mavenResolver = Maven.configureResolver().withRemoteRepo("Fabric", "http://maven.fabricmc.net/", "default").withRemoteRepo("SpongePowered", "http://repo.spongepowered.org/maven/", "default").withRemoteRepo("Mojang", "https://libraries.minecraft.net/", "default");
File[] files = mavenResolver.resolve("net.fabricmc:fabric-base:16w38a-0.0.4-SNAPSHOT").withTransitivity().asFile();
for (File file : files) {
addFile(file, this);
}
}
public static void addFile(File file, Object object) {
try {
URLClassLoader classLoader = (URLClassLoader) object.getClass().getClassLoader();
Class urlClassLoaderClass = URLClassLoader.class;
Method method = urlClassLoaderClass.getDeclaredMethod("addURL", URL.class);
method.setAccessible(true);
method.invoke(classLoader, file.toURI().toURL());
} catch (NoSuchMethodException | IllegalAccessException | MalformedURLException | InvocationTargetException e) {
e.printStackTrace();
}
}
}

View File

@ -65,7 +65,7 @@ public class RunClientTask extends JavaExec {
libs.add(file.getAbsolutePath()); libs.add(file.getAbsolutePath());
} }
} }
libs.add(Constants.MINECRAFT_MAPPED_JAR.get(extension).getAbsolutePath()); libs.add(Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath());
classpath(libs); classpath(libs);
args("--tweakClass", "net.fabricmc.base.launch.FabricClientTweaker", "--assetIndex", version.assetIndex.id, "--assetsDir", new File(extension.getFabricUserCache(), "assets-" + extension.version).getAbsolutePath()); args("--tweakClass", "net.fabricmc.base.launch.FabricClientTweaker", "--assetIndex", version.assetIndex.id, "--assetsDir", new File(extension.getFabricUserCache(), "assets-" + extension.version).getAbsolutePath());

View File

@ -62,7 +62,7 @@ public class RunServerTask extends JavaExec {
libs.add(file.getAbsolutePath()); libs.add(file.getAbsolutePath());
} }
} }
libs.add(Constants.MINECRAFT_MAPPED_JAR.get(extension).getAbsolutePath()); libs.add(Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath());
classpath(libs); classpath(libs);
args("--tweakClass", "net.fabricmc.base.launch.FabricServerTweaker"); args("--tweakClass", "net.fabricmc.base.launch.FabricServerTweaker");

View File

@ -41,6 +41,7 @@ public class Constants {
public static final IDelayed<File> MINECRAFT_SERVER_JAR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-server.jar")); public static final IDelayed<File> MINECRAFT_SERVER_JAR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-server.jar"));
public static final IDelayed<File> MINECRAFT_MERGED_JAR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-merged.jar")); public static final IDelayed<File> MINECRAFT_MERGED_JAR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-merged.jar"));
public static final IDelayed<File> MINECRAFT_MAPPED_JAR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.getVersionString() + "-mapped-" + extension.pomfVersion + ".jar")); public static final IDelayed<File> MINECRAFT_MAPPED_JAR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.getVersionString() + "-mapped-" + extension.pomfVersion + ".jar"));
public static final IDelayed<File> MINECRAFT_FINAL_JAR = new DelayedFile(extension -> new File(CACHE_FILES, extension.getVersionString() + "-mixed-" + extension.pomfVersion + ".jar"));
//http://asie.pl:8080/job/pomf/1/artifact/build/libs/pomf-enigma-16w33a.1.zip //http://asie.pl:8080/job/pomf/1/artifact/build/libs/pomf-enigma-16w33a.1.zip
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"));
@ -65,6 +66,7 @@ public class Constants {
public static final String CONFIG_MC_DEPENDENCIES = "MC_DEPENDENCIES"; public static final String CONFIG_MC_DEPENDENCIES = "MC_DEPENDENCIES";
public static final String CONFIG_MC_DEPENDENCIES_CLIENT = "MC_DEPENDENCIES_CLIENT"; public static final String CONFIG_MC_DEPENDENCIES_CLIENT = "MC_DEPENDENCIES_CLIENT";
public static final String SYSTEM_ARCH = System.getProperty("os.arch").equals("64") ? "64" : "32"; public static final String SYSTEM_ARCH = System.getProperty("os.arch").equals("64") ? "64" : "32";
public static final String COMPILE_MODS = "modCompile";
public static List<String> getClassPath() { public static List<String> getClassPath() {
URL[] urls = ((URLClassLoader) Constants.class.getClassLoader()).getURLs(); URL[] urls = ((URLClassLoader) Constants.class.getClassLoader()).getURLs();

View File

@ -0,0 +1,53 @@
/*
* This file is part of fabric-loom, licensed under the MIT License (MIT).
*
* Copyright (c) 2016 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.util.proccessing;
import net.fabricmc.base.util.MixinPrebaker;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.task.ProcessModsTask;
import net.fabricmc.loom.util.Constants;
import org.apache.logging.log4j.LogManager;
import org.gradle.api.Project;
import java.io.File;
import java.util.List;
public class PreBakeMixins {
public void proccess(Project project, LoomGradleExtension extension, List<File> mods) {
project.getLogger().lifecycle(":Found " + mods.size() + " mods to prebake");
String[] args = new String[mods.size() + 2];
args[0] = Constants.MINECRAFT_MAPPED_JAR.get(extension).getAbsolutePath();
args[1] = Constants.MINECRAFT_FINAL_JAR.get(extension).getAbsolutePath();
for (int i = 0; i < mods.size(); i++) {
args[i + 2] = mods.get(i).getAbsolutePath();
}
project.getLogger().lifecycle(":preBaking mixins");
ProcessModsTask.addFile(Constants.MINECRAFT_MAPPED_JAR.get(extension), this);
LogManager.getFormatterLogger("test");
MixinPrebaker.main(args);
}
}