From 0bb8d63809038dc4d2e29c77faf8412a0bb01b39 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 2 Oct 2016 11:58:41 -0400 Subject: [PATCH] Use classpath Weave instead of downloading --- build.gradle | 89 +++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 54 deletions(-) diff --git a/build.gradle b/build.gradle index 0add88e2bd..dfe657012e 100644 --- a/build.gradle +++ b/build.gradle @@ -1,18 +1,18 @@ buildscript { - repositories { - jcenter() - maven { - name = "Fabric" - url = "http://maven.fabricmc.net/" - } - } - dependencies { - classpath("net.fabricmc:weave:0.1.0.6") { - exclude module: 'procyon-compilertools' - } - classpath "commons-io:commons-io:1.4" - classpath "com.google.guava:guava:19.0" - } + repositories { + jcenter() + maven { + name = "Fabric" + url = "http://maven.fabricmc.net/" + } + } + dependencies { + classpath("net.fabricmc:weave:0.1.0.6") { + exclude module: 'procyon-compilertools' + } + classpath "commons-io:commons-io:1.4" + classpath "com.google.guava:guava:19.0" + } } def minecraft_version = "16w38a" @@ -21,7 +21,7 @@ def pomfVersion = "${minecraft_version}" def ENV = System.getenv() if (ENV.BUILD_NUMBER) { - pomfVersion = pomfVersion + "." + "${System.getenv().BUILD_NUMBER}" + pomfVersion = pomfVersion + "." + "${System.getenv().BUILD_NUMBER}" } import groovy.json.JsonSlurper @@ -30,6 +30,7 @@ import com.google.common.hash.HashCode import com.google.common.hash.Hashing import com.google.common.io.Files import net.fabricmc.weave.merge.JarMerger +import net.fabricmc.weave.CommandTinyify import groovy.util.XmlSlurper import java.io.FileInputStream; import java.io.FileOutputStream; @@ -144,57 +145,37 @@ task build(type: Zip) { } task buildTiny << { - def cacheFiles = new File(".gradle/weave") - if (!cacheFiles.exists()) cacheFiles.mkdirs() - - def mavenMetadata = new File(cacheFiles, "maven-metadata.xml") - - logger.lifecycle(":downloading weave metadata") - FileUtils.copyURLToFile(new URL("http://maven.fabricmc.net/net/fabricmc/weave/maven-metadata.xml"), mavenMetadata) - - def metadata = new XmlSlurper().parseText(FileUtils.readFileToString(mavenMetadata)) - def weaveVersion = metadata.versioning.release - - def weave = new File(cacheFiles, "${weaveVersion}.jar") - - if(!weave.exists()){ - logger.lifecycle(":downloading weave") - FileUtils.copyURLToFile(new URL("http://maven.fabricmc.net/net/fabricmc/weave/${weaveVersion}/weave-${weaveVersion}-fat.jar"), weave) - } - - logger.lifecycle(":generating tiny mappings") - ant.java(jar: weave.getAbsolutePath(), fork: true, spawn: false) { - arg(value : "tinyify") - arg(value: new File("${minecraft_version}-merged.jar").getAbsolutePath()) - arg(value: new File("mappings").getAbsolutePath()) - arg(value : "mappings.tiny") - arg(value : "mojang") - arg(value : "pomf") - } + String[] args = [ + new File("${minecraft_version}-merged.jar").getAbsolutePath(), + new File("mappings").getAbsolutePath(), + "mappings.tiny", + "moajng", + "pomf" + ] + + new CommandTinyify().run(args) logger.lifecycle(":compressing tiny mappings") def libs = new File("build/libs/") - if(!libs.exists()){ - libs.mkdirs() - } + if (!libs.exists()) libs.mkdirs() def buffer = new byte[1024] def outputFile = new File(libs, "pomf-tiny-${pomfVersion}.gz") def fileOutputStream = new FileOutputStream(outputFile) - def outputStream = new GZIPOutputStream(fileOutputStream) + def outputStream = new GZIPOutputStream(fileOutputStream) def inputFile = new File("mappings.tiny") - def fileInputStream = new FileInputStream(inputFile) + def fileInputStream = new FileInputStream(inputFile) - def length; - while ((length = fileInputStream.read(buffer)) > 0) { - outputStream.write(buffer, 0, length); - } + def length + while ((length = fileInputStream.read(buffer)) > 0) { + outputStream.write(buffer, 0, length) + } - fileInputStream.close() - outputStream.finish() - outputStream.close() + fileInputStream.close() + outputStream.finish() + outputStream.close() inputFile.delete() }