Use pomf releases, build against gradle 3

dev/0.11
modmuss50 2016-09-10 13:09:15 +01:00
parent 3072d34e47
commit 5da73c87f8
9 changed files with 63 additions and 57 deletions

View File

@ -14,7 +14,7 @@ targetCompatibility = 1.8
group = 'net.fabricmc'
archivesBaseName = project.name.toLowerCase()
version = '0.0.1-SNAPSHOT'
version = '0.0.2-SNAPSHOT'
repositories {
mavenCentral()
@ -126,5 +126,5 @@ uploadArchives {
}
task wrapper(type: Wrapper) {
gradleVersion = '2.14.1'
gradleVersion = '3.0'
}

View File

@ -1,6 +1,6 @@
#Tue Aug 16 23:25:19 BST 2016
#Sat Sep 10 13:02:22 BST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-all.zip

View File

@ -209,21 +209,21 @@ public class AbstractPlugin implements Plugin<Project> {
}
protected void readModJson(LoomGradleExtension extension){
protected void readModJson(LoomGradleExtension extension) {
File resDir = new File(project.getProjectDir(), "src" + File.separator + "main" + File.separator + "resources");
File modJson = new File(resDir, "mod.json");
if(modJson.exists()){
if (modJson.exists()) {
Gson gson = new Gson();
try {
JsonElement jsonElement = gson.fromJson(new FileReader(modJson), JsonElement.class);
JsonObject jsonObject = jsonElement.getAsJsonObject();
if((extension.version == null || extension.version.isEmpty()) && jsonObject.has("version")){
if ((extension.version == null || extension.version.isEmpty()) && jsonObject.has("version")) {
project.setVersion(jsonObject.get("version").getAsString());
}
if(jsonObject.has("group")){
if (jsonObject.has("group")) {
project.setGroup(jsonObject.get("group").getAsString());
}
if(jsonObject.has("description")){
if (jsonObject.has("description")) {
project.setDescription(jsonObject.get("description").getAsString());
}
//TODO load deps

View File

@ -32,6 +32,7 @@ public class LoomGradleExtension {
public String version;
public String runDir = "run";
public String fabricVersion;
public String pomf;
//Not to be set in the build.gradle
public Project project;

View File

@ -45,6 +45,7 @@ import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Map;
import java.util.Optional;
@ -69,12 +70,14 @@ public class DownloadTask extends DefaultTask {
FileUtils.copyURLToFile(new URL(version.downloads.get("server").url), Constants.MINECRAFT_SERVER_JAR.get(extension));
}
if (Constants.MAPPINGS_ZIP.exists()) {
Constants.MAPPINGS_ZIP.delete();
if (!Constants.POMF_DIR.get(extension).exists()) {
Constants.POMF_DIR.get(extension).mkdir();
}
this.getLogger().lifecycle(":downloading mappings");
FileUtils.copyURLToFile(new URL("https://github.com/FabricMC/pomf/archive/" + extension.version + ".zip"), Constants.MAPPINGS_ZIP);
if (!Constants.MAPPINGS_ZIP.get(extension).exists()) {
this.getLogger().lifecycle(":downloading mappings");
FileUtils.copyURLToFile(new URL("http://asie.pl:8080/job/pomf/" + extension.pomf + "/artifact/build/libs/pomf-enigma-" + extension.version + "." + extension.pomf + ".zip"), Constants.MAPPINGS_ZIP.get(extension));
}
DependencyHandler dependencyHandler = getProject().getDependencies();
@ -144,7 +147,7 @@ public class DownloadTask extends DefaultTask {
if (!Constants.MINECRAFT_JSON.get(extension).exists()) {
logger.lifecycle(":downloading minecraft json");
FileUtils.copyURLToFile(new URL("https://launchermeta.mojang.com/mc/game/version_manifest.json"), Constants.VERSION_MANIFEST.get(extension));
ManifestVersion mcManifest = new GsonBuilder().create().fromJson(FileUtils.readFileToString(Constants.VERSION_MANIFEST.get(extension)), ManifestVersion.class);
ManifestVersion mcManifest = new GsonBuilder().create().fromJson(FileUtils.readFileToString(Constants.VERSION_MANIFEST.get(extension), Charset.defaultCharset()), ManifestVersion.class);
Optional<ManifestVersion.Versions> optionalVersion = mcManifest.versions.stream().filter(versions -> versions.id.equalsIgnoreCase(extension.version)).findFirst();
if (optionalVersion.isPresent()) {

View File

@ -156,7 +156,7 @@ public class GenIdeaProjectTask extends DefaultTask {
ideaClient.projectName = getProject().getName();
ideaClient.configName = "Minecraft Client";
ideaClient.runDir = "file://$PROJECT_DIR$/" + extension.runDir;
ideaClient.vmArgs = "-Djava.library.path=" + Constants.MINECRAFT_NATIVES.get(extension).getAbsolutePath() + " -Dfabric.development=true";
ideaClient.vmArgs = "-Djava.library.path=" + Constants.MINECRAFT_NATIVES.get(extension).getAbsolutePath() + " -Dfabric.development=true";
ideaClient.programArgs = "--tweakClass net.fabricmc.base.launch.FabricClientTweaker --assetIndex " + version.assetIndex.id + " --assetsDir " + new File(extension.getFabricUserCache(), "assets-" + extension.version).getAbsolutePath();
runManager.appendChild(ideaClient.genRuns(runManager));

View File

@ -26,7 +26,6 @@ package net.fabricmc.loom.task;
import cuchaz.enigma.Deobfuscator;
import cuchaz.enigma.TranslatingTypeLoader;
import cuchaz.enigma.bytecode.ClassPublifier;
import cuchaz.enigma.mapping.MappingsEnigmaReader;
import cuchaz.enigma.mapping.TranslationDirection;
import cuchaz.enigma.throwables.MappingParseException;
@ -37,7 +36,6 @@ import javassist.bytecode.AccessFlag;
import javassist.bytecode.InnerClassesAttribute;
import net.fabricmc.loom.LoomGradleExtension;
import net.fabricmc.loom.util.Constants;
import org.apache.commons.io.FileUtils;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;
import org.zeroturnaround.zip.ZipUtil;
@ -53,33 +51,33 @@ public class MapJarsTask extends DefaultTask {
@TaskAction
public void mapJars() throws IOException, MappingParseException {
LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class);
this.getLogger().lifecycle(":unpacking mappings");
if (Constants.MAPPINGS_DIR.exists()) {
FileUtils.deleteDirectory(Constants.MAPPINGS_DIR);
}
if (Constants.MINECRAFT_MAPPED_JAR.get(extension).exists()) {
Constants.MINECRAFT_MAPPED_JAR.get(extension).delete();
}
ZipUtil.unpack(Constants.MAPPINGS_ZIP, Constants.MAPPINGS_DIR);
this.getLogger().lifecycle(":remapping jar");
deobfuscator = new Deobfuscator(new JarFile(Constants.MINECRAFT_MERGED_JAR.get(extension)));
this.deobfuscator.setMappings(new MappingsEnigmaReader().read(new File(Constants.MAPPINGS_DIR, "pomf-" + extension.version + File.separator + "mappings")));
writeJar(Constants.MINECRAFT_MAPPED_JAR.get(extension), new ProgressListener(), deobfuscator);
File tempAssests = new File(Constants.CACHE_FILES, "tempAssets");
ZipUtil.unpack(Constants.MINECRAFT_CLIENT_JAR.get(extension), tempAssests, name -> {
if (name.startsWith("assets") || name.startsWith("log4j2.xml") || name.startsWith("pack.png")) {
return name;
} else {
return null;
if (!Constants.MINECRAFT_MAPPED_JAR.get(extension).exists()) {
this.getLogger().lifecycle(":unpacking mappings");
if (!Constants.MAPPINGS_DIR.get(extension).exists()) {
ZipUtil.unpack(Constants.MAPPINGS_ZIP.get(extension), Constants.MAPPINGS_DIR.get(extension));
}
});
ZipUtil.unpack(Constants.MINECRAFT_MAPPED_JAR.get(extension), tempAssests);
ZipUtil.pack(tempAssests, Constants.MINECRAFT_MAPPED_JAR.get(extension));
this.getLogger().lifecycle(":remapping jar");
deobfuscator = new Deobfuscator(new JarFile(Constants.MINECRAFT_MERGED_JAR.get(extension)));
this.deobfuscator.setMappings(new MappingsEnigmaReader().read(Constants.MAPPINGS_DIR.get(extension)));
writeJar(Constants.MINECRAFT_MAPPED_JAR.get(extension), new ProgressListener(), deobfuscator);
File tempAssests = new File(Constants.CACHE_FILES, "tempAssets");
ZipUtil.unpack(Constants.MINECRAFT_CLIENT_JAR.get(extension), tempAssests, name -> {
if (name.startsWith("assets") || name.startsWith("log4j2.xml") || name.startsWith("pack.png")) {
return name;
} else {
return null;
}
});
ZipUtil.unpack(Constants.MINECRAFT_MAPPED_JAR.get(extension), tempAssests);
ZipUtil.pack(tempAssests, Constants.MINECRAFT_MAPPED_JAR.get(extension));
} else {
this.getLogger().lifecycle(":mapped jar found, skipping mapping");
}
}
public void writeJar(File out, Deobfuscator.ProgressListener progress, Deobfuscator deobfuscator) {
@ -127,7 +125,6 @@ public class MapJarsTask extends DefaultTask {
return flags;
}
public static class ProgressListener implements Deobfuscator.ProgressListener {
@Override
public void init(int i, String s) {

View File

@ -38,22 +38,25 @@ public class MergeJarsTask extends DefaultTask {
@TaskAction
public void mergeJars() throws IOException {
this.getLogger().lifecycle(":merging jars");
LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class);
FileInputStream client = new FileInputStream(Constants.MINECRAFT_CLIENT_JAR.get(extension));
FileInputStream server = new FileInputStream(Constants.MINECRAFT_SERVER_JAR.get(extension));
FileOutputStream merged = new FileOutputStream(Constants.MINECRAFT_MERGED_JAR.get(extension));
if(!Constants.MINECRAFT_MERGED_JAR.get(extension).exists()){
this.getLogger().lifecycle(":merging jars");
FileInputStream client = new FileInputStream(Constants.MINECRAFT_CLIENT_JAR.get(extension));
FileInputStream server = new FileInputStream(Constants.MINECRAFT_SERVER_JAR.get(extension));
FileOutputStream merged = new FileOutputStream(Constants.MINECRAFT_MERGED_JAR.get(extension));
JarMerger jarMerger = new JarMerger(client, server, merged);
JarMerger jarMerger = new JarMerger(client, server, merged);
jarMerger.merge();
jarMerger.close();
client.close();
server.close();
merged.close();
jarMerger.merge();
jarMerger.close();
client.close();
server.close();
merged.close();
} else {
this.getLogger().lifecycle(":merged jar found, skipping");
}
}
}

View File

@ -39,11 +39,13 @@ public class Constants {
public static final IDelayed<File> MINECRAFT_CLIENT_JAR = new DelayedFile(extension -> new File(extension.getFabricUserCache(), extension.version + "-client.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(CACHE_FILES, extension.version + "-merged.jar"));
public static final IDelayed<File> MINECRAFT_MAPPED_JAR = new DelayedFile(extension -> new File(CACHE_FILES, extension.getVersionString() + "-mapped.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.pomf + ".jar"));
public static final File MAPPINGS_ZIP = new File(CACHE_FILES, "mappings.zip");
public static final File MAPPINGS_DIR = new File(CACHE_FILES, "mappings");
//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> MAPPINGS_ZIP = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomf + ".zip"));
public static final IDelayed<File> MAPPINGS_DIR = new DelayedFile(extension -> new File(POMF_DIR.get(extension), "pomf-enigma-" + extension.version + "." + extension.pomf + ""));
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"));