import java.util.jar.JarEntry import java.util.jar.JarFile import java.util.jar.JarOutputStream /* * This file is part of Baritone. * * Baritone is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Baritone is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Baritone. If not, see . */ group 'baritone' version '0.0.6' buildscript { repositories { maven { name = 'forge' url = 'http://files.minecraftforge.net/maven' } maven { name = 'SpongePowered' url = 'http://repo.spongepowered.org/maven' } jcenter() } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT' } } apply plugin: 'java' apply plugin: 'net.minecraftforge.gradle.tweaker-client' apply plugin: 'org.spongepowered.mixin' sourceCompatibility = targetCompatibility = '1.8' compileJava { sourceCompatibility = targetCompatibility = '1.8' } sourceSets { launch { compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output } } minecraft { version = '1.12.2' mappings = 'snapshot_20180731' tweakClass = 'baritone.launch.BaritoneTweaker' runDir = 'run' makeObfSourceJar = false } repositories { mavenCentral() maven { name = 'spongepowered-repo' url = 'http://repo.spongepowered.org/maven/' } } dependencies { runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') { // Mixin includes a lot of dependencies that are too up-to-date exclude module: 'launchwrapper' exclude module: 'guava' exclude module: 'gson' exclude module: 'commons-io' exclude module: 'log4j-core' } testImplementation 'junit:junit:4.12' } mixin { defaultObfuscationEnv notch add sourceSets.launch, 'mixins.baritone.refmap.json' } jar { from sourceSets.launch.output, sourceSets.api.output preserveFileTimestamps = false reproducibleFileOrder = true } build { // while "jar" supports preserveFileTimestamps false // reobfJar doesn't, it just sets all the last modified times to that instant where it runs the reobfuscator // so we have to set all those last modified times back to zero doLast { JarFile jf = new JarFile("build/libs/baritone-" + version + ".jar") JarOutputStream jos = new JarOutputStream(new FileOutputStream(new File("build/libs/baritone-unoptimized-" + version + ".jar"))) jf.entries().unique { it.name }.sort { it.name }.each { cloneAndCopyEntry(jf, it, jos, 0) } jos.finish() jf.close() } } void cloneAndCopyEntry(JarFile originalFile, JarEntry original, JarOutputStream jos, long newTimestamp) { JarEntry clone = new JarEntry(original) clone.time = newTimestamp def entryIs = originalFile.getInputStream(original) jos.putNextEntry(clone) copyBinaryData(entryIs, jos) } void copyBinaryData(InputStream is, JarOutputStream jos) { byte[] buffer = new byte[1024] int len = 0 while ((len = is.read(buffer)) != -1) { jos.write(buffer, 0, len) } } gradle.taskGraph.whenReady { taskGraph -> println "Found task graph: " + taskGraph println "Found " + taskGraph.allTasks.size() + " tasks." taskGraph.allTasks.forEach { task -> println task task.dependsOn.forEach { dep -> println " - " + dep } } }