Use pomf releases, build against gradle 3
This commit is contained in:
		
							parent
							
								
									3072d34e47
								
							
						
					
					
						commit
						5da73c87f8
					
				
					 9 changed files with 63 additions and 57 deletions
				
			
		|  | @ -14,7 +14,7 @@ targetCompatibility = 1.8 | ||||||
| 
 | 
 | ||||||
| group = 'net.fabricmc' | group = 'net.fabricmc' | ||||||
| archivesBaseName = project.name.toLowerCase() | archivesBaseName = project.name.toLowerCase() | ||||||
| version = '0.0.1-SNAPSHOT' | version = '0.0.2-SNAPSHOT' | ||||||
| 
 | 
 | ||||||
| repositories { | repositories { | ||||||
|     mavenCentral() |     mavenCentral() | ||||||
|  | @ -126,5 +126,5 @@ uploadArchives { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| task wrapper(type: Wrapper) { | task wrapper(type: Wrapper) { | ||||||
|     gradleVersion = '2.14.1' |     gradleVersion = '3.0' | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								gradle/wrapper/gradle-wrapper.properties
									
									
									
									
										vendored
									
									
								
							|  | @ -1,6 +1,6 @@ | ||||||
| #Tue Aug 16 23:25:19 BST 2016 | #Sat Sep 10 13:02:22 BST 2016 | ||||||
| distributionBase=GRADLE_USER_HOME | distributionBase=GRADLE_USER_HOME | ||||||
| distributionPath=wrapper/dists | distributionPath=wrapper/dists | ||||||
| zipStoreBase=GRADLE_USER_HOME | zipStoreBase=GRADLE_USER_HOME | ||||||
| zipStorePath=wrapper/dists | 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 | ||||||
|  |  | ||||||
|  | @ -32,6 +32,7 @@ public class LoomGradleExtension { | ||||||
| 	public String version; | 	public String version; | ||||||
| 	public String runDir = "run"; | 	public String runDir = "run"; | ||||||
| 	public String fabricVersion; | 	public String fabricVersion; | ||||||
|  | 	public String pomf; | ||||||
| 
 | 
 | ||||||
| 	//Not to be set in the build.gradle | 	//Not to be set in the build.gradle | ||||||
| 	public Project project; | 	public Project project; | ||||||
|  |  | ||||||
|  | @ -45,6 +45,7 @@ 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; | ||||||
| 
 | 
 | ||||||
|  | @ -69,12 +70,14 @@ public class DownloadTask extends DefaultTask { | ||||||
| 				FileUtils.copyURLToFile(new URL(version.downloads.get("server").url), Constants.MINECRAFT_SERVER_JAR.get(extension)); | 				FileUtils.copyURLToFile(new URL(version.downloads.get("server").url), Constants.MINECRAFT_SERVER_JAR.get(extension)); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			if (Constants.MAPPINGS_ZIP.exists()) { | 			if (!Constants.POMF_DIR.get(extension).exists()) { | ||||||
| 				Constants.MAPPINGS_ZIP.delete(); | 				Constants.POMF_DIR.get(extension).mkdir(); | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
|  | 			if (!Constants.MAPPINGS_ZIP.get(extension).exists()) { | ||||||
| 				this.getLogger().lifecycle(":downloading mappings"); | 				this.getLogger().lifecycle(":downloading mappings"); | ||||||
| 			FileUtils.copyURLToFile(new URL("https://github.com/FabricMC/pomf/archive/" + extension.version + ".zip"), Constants.MAPPINGS_ZIP); | 				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(); | 			DependencyHandler dependencyHandler = getProject().getDependencies(); | ||||||
| 
 | 
 | ||||||
|  | @ -144,7 +147,7 @@ public class DownloadTask extends DefaultTask { | ||||||
| 		if (!Constants.MINECRAFT_JSON.get(extension).exists()) { | 		if (!Constants.MINECRAFT_JSON.get(extension).exists()) { | ||||||
| 			logger.lifecycle(":downloading minecraft json"); | 			logger.lifecycle(":downloading minecraft json"); | ||||||
| 			FileUtils.copyURLToFile(new URL("https://launchermeta.mojang.com/mc/game/version_manifest.json"), Constants.VERSION_MANIFEST.get(extension)); | 			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(); | 			Optional<ManifestVersion.Versions> optionalVersion = mcManifest.versions.stream().filter(versions -> versions.id.equalsIgnoreCase(extension.version)).findFirst(); | ||||||
| 			if (optionalVersion.isPresent()) { | 			if (optionalVersion.isPresent()) { | ||||||
|  |  | ||||||
|  | @ -26,7 +26,6 @@ package net.fabricmc.loom.task; | ||||||
| 
 | 
 | ||||||
| import cuchaz.enigma.Deobfuscator; | import cuchaz.enigma.Deobfuscator; | ||||||
| import cuchaz.enigma.TranslatingTypeLoader; | import cuchaz.enigma.TranslatingTypeLoader; | ||||||
| import cuchaz.enigma.bytecode.ClassPublifier; |  | ||||||
| import cuchaz.enigma.mapping.MappingsEnigmaReader; | import cuchaz.enigma.mapping.MappingsEnigmaReader; | ||||||
| import cuchaz.enigma.mapping.TranslationDirection; | import cuchaz.enigma.mapping.TranslationDirection; | ||||||
| import cuchaz.enigma.throwables.MappingParseException; | import cuchaz.enigma.throwables.MappingParseException; | ||||||
|  | @ -37,7 +36,6 @@ import javassist.bytecode.AccessFlag; | ||||||
| import javassist.bytecode.InnerClassesAttribute; | import javassist.bytecode.InnerClassesAttribute; | ||||||
| import net.fabricmc.loom.LoomGradleExtension; | import net.fabricmc.loom.LoomGradleExtension; | ||||||
| import net.fabricmc.loom.util.Constants; | import net.fabricmc.loom.util.Constants; | ||||||
| import org.apache.commons.io.FileUtils; |  | ||||||
| import org.gradle.api.DefaultTask; | import org.gradle.api.DefaultTask; | ||||||
| import org.gradle.api.tasks.TaskAction; | import org.gradle.api.tasks.TaskAction; | ||||||
| import org.zeroturnaround.zip.ZipUtil; | import org.zeroturnaround.zip.ZipUtil; | ||||||
|  | @ -53,19 +51,16 @@ 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); | ||||||
| 		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); |  | ||||||
| 
 | 
 | ||||||
|  | 		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)); | ||||||
|  | 			} | ||||||
| 
 | 
 | ||||||
| 			this.getLogger().lifecycle(":remapping jar"); | 			this.getLogger().lifecycle(":remapping jar"); | ||||||
| 			deobfuscator = new Deobfuscator(new JarFile(Constants.MINECRAFT_MERGED_JAR.get(extension))); | 			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"))); | 			this.deobfuscator.setMappings(new MappingsEnigmaReader().read(Constants.MAPPINGS_DIR.get(extension))); | ||||||
| 			writeJar(Constants.MINECRAFT_MAPPED_JAR.get(extension), new ProgressListener(), deobfuscator); | 			writeJar(Constants.MINECRAFT_MAPPED_JAR.get(extension), new ProgressListener(), deobfuscator); | ||||||
| 
 | 
 | ||||||
| 			File tempAssests = new File(Constants.CACHE_FILES, "tempAssets"); | 			File tempAssests = new File(Constants.CACHE_FILES, "tempAssets"); | ||||||
|  | @ -80,6 +75,9 @@ public class MapJarsTask extends DefaultTask { | ||||||
| 			ZipUtil.unpack(Constants.MINECRAFT_MAPPED_JAR.get(extension), tempAssests); | 			ZipUtil.unpack(Constants.MINECRAFT_MAPPED_JAR.get(extension), tempAssests); | ||||||
| 
 | 
 | ||||||
| 			ZipUtil.pack(tempAssests, Constants.MINECRAFT_MAPPED_JAR.get(extension)); | 			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) { | 	public void writeJar(File out, Deobfuscator.ProgressListener progress, Deobfuscator deobfuscator) { | ||||||
|  | @ -127,7 +125,6 @@ public class MapJarsTask extends DefaultTask { | ||||||
| 		return flags; | 		return flags; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 	public static class ProgressListener implements Deobfuscator.ProgressListener { | 	public static class ProgressListener implements Deobfuscator.ProgressListener { | ||||||
| 		@Override | 		@Override | ||||||
| 		public void init(int i, String s) { | 		public void init(int i, String s) { | ||||||
|  |  | ||||||
|  | @ -38,9 +38,10 @@ public class MergeJarsTask extends DefaultTask { | ||||||
| 
 | 
 | ||||||
| 	@TaskAction | 	@TaskAction | ||||||
| 	public void mergeJars() throws IOException { | 	public void mergeJars() throws IOException { | ||||||
| 		this.getLogger().lifecycle(":merging jars"); |  | ||||||
| 		LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class); | 		LoomGradleExtension extension = this.getProject().getExtensions().getByType(LoomGradleExtension.class); | ||||||
| 
 | 
 | ||||||
|  | 		if(!Constants.MINECRAFT_MERGED_JAR.get(extension).exists()){ | ||||||
|  | 			this.getLogger().lifecycle(":merging jars"); | ||||||
| 			FileInputStream client = new FileInputStream(Constants.MINECRAFT_CLIENT_JAR.get(extension)); | 			FileInputStream client = new FileInputStream(Constants.MINECRAFT_CLIENT_JAR.get(extension)); | ||||||
| 			FileInputStream server = new FileInputStream(Constants.MINECRAFT_SERVER_JAR.get(extension)); | 			FileInputStream server = new FileInputStream(Constants.MINECRAFT_SERVER_JAR.get(extension)); | ||||||
| 			FileOutputStream merged = new FileOutputStream(Constants.MINECRAFT_MERGED_JAR.get(extension)); | 			FileOutputStream merged = new FileOutputStream(Constants.MINECRAFT_MERGED_JAR.get(extension)); | ||||||
|  | @ -53,7 +54,9 @@ public class MergeJarsTask extends DefaultTask { | ||||||
| 			client.close(); | 			client.close(); | ||||||
| 			server.close(); | 			server.close(); | ||||||
| 			merged.close(); | 			merged.close(); | ||||||
| 
 | 		} else { | ||||||
|  | 			this.getLogger().lifecycle(":merged jar found, skipping"); | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -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_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_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_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(CACHE_FILES, extension.getVersionString() + "-mapped.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"); | 	//http://asie.pl:8080/job/pomf/1/artifact/build/libs/pomf-enigma-16w33a.1.zip | ||||||
| 	public static final File MAPPINGS_DIR = new File(CACHE_FILES, "mappings"); | 	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_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")); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue