mirror of https://github.com/cabaletta/baritone
1.12.2 build script overhaul.
- Updated to ForgeGradle 4.0, MixinGradle 0.7 and Gradle 6.9.4 - Added a hack to run the game on arm64 on Mac OS X natively.
This commit is contained in:
parent
800cb2e747
commit
cb7c2d7171
|
@ -30,3 +30,5 @@ baritone_Client.launch
|
||||||
|
|
||||||
.vscode/launch.json
|
.vscode/launch.json
|
||||||
|
|
||||||
|
libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar
|
||||||
|
libs/java-objc-bridge-1.1.jar
|
||||||
|
|
138
build.gradle
138
build.gradle
|
@ -22,7 +22,7 @@ buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
maven {
|
||||||
name = 'forge'
|
name = 'forge'
|
||||||
url = 'http://files.minecraftforge.net/maven'
|
url = 'https://files.minecraftforge.net/maven'
|
||||||
}
|
}
|
||||||
maven {
|
maven {
|
||||||
name = 'SpongePowered'
|
name = 'SpongePowered'
|
||||||
|
@ -32,18 +32,19 @@ buildscript {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
classpath 'net.minecraftforge.gradle:ForgeGradle:4.+' // TODO: 5.+. `doHackyStuff` relies on 4.x internals.
|
||||||
classpath 'org.spongepowered:mixingradle:0.6-SNAPSHOT'
|
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
import baritone.gradle.task.CreateDistTask
|
import baritone.gradle.task.CreateDistTask
|
||||||
import baritone.gradle.task.ProguardTask
|
import baritone.gradle.task.ProguardTask
|
||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'maven'
|
apply plugin: 'maven-publish'
|
||||||
apply plugin: 'net.minecraftforge.gradle.tweaker-client'
|
apply plugin: 'net.minecraftforge.gradle'
|
||||||
|
apply from: 'hacks.gradle'
|
||||||
|
ext.doHackyStuff(Class.forName('net.minecraftforge.gradle.mcp.task.GenerateSRG')) // TODO: fg 5.0 - `ext.doHackyStuff(Class.forName('net.minecraftforge.gradle.mcp.tasks.GenerateSRG'))`
|
||||||
apply plugin: 'org.spongepowered.mixin'
|
apply plugin: 'org.spongepowered.mixin'
|
||||||
|
|
||||||
sourceCompatibility = targetCompatibility = '1.8'
|
sourceCompatibility = targetCompatibility = '1.8'
|
||||||
|
@ -53,8 +54,19 @@ compileJava {
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
|
api {
|
||||||
|
compileClasspath += main.compileClasspath
|
||||||
|
}
|
||||||
|
main {
|
||||||
|
compileClasspath += api.output
|
||||||
|
}
|
||||||
|
test {
|
||||||
|
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||||
|
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||||
|
}
|
||||||
launch {
|
launch {
|
||||||
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
compileClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||||
|
runtimeClasspath += main.compileClasspath + main.runtimeClasspath + main.output
|
||||||
}
|
}
|
||||||
|
|
||||||
schematica_api {
|
schematica_api {
|
||||||
|
@ -67,13 +79,26 @@ sourceSets {
|
||||||
}
|
}
|
||||||
|
|
||||||
minecraft {
|
minecraft {
|
||||||
version = '1.12.2'
|
mappings channel: 'stable', version: '39-1.12'
|
||||||
mappings = 'stable_39'
|
runs {
|
||||||
tweakClass = 'baritone.launch.BaritoneTweaker'
|
def nativesOutput = extractNatives.output // TODO: fg 5.0 - `def nativesOutput = extractNatives.output.get()`
|
||||||
runDir = 'run'
|
println("[Baritoe] Detected natives: ${nativesOutput}")
|
||||||
|
client {
|
||||||
|
workingDirectory project.file('run')
|
||||||
|
source sourceSets.launch
|
||||||
|
|
||||||
// The sources jar should use SRG names not MCP to ensure compatibility with all mappings
|
main 'net.minecraft.launchwrapper.Launch'
|
||||||
makeObfSourceJar = true
|
|
||||||
|
args '--gameDir', '.'
|
||||||
|
args '--version', '1.12.2'
|
||||||
|
args '--assetsDir', downloadAssets.output
|
||||||
|
args '--assetIndex', '{asset_index}'
|
||||||
|
args '--accessToken', 'INVALID'
|
||||||
|
|
||||||
|
args '--tweakClass', 'baritone.launch.BaritoneTweaker'
|
||||||
|
jvmArgs "-Dorg.lwjgl.librarypath=${nativesOutput}"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -95,23 +120,66 @@ repositories {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
// fix forge gradle 4+ bug with 1.12.2
|
||||||
runtime launchCompile('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
afterEvaluate {
|
||||||
runtime launchCompile('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
configurations.minecraft {
|
||||||
// Mixin includes a lot of dependencies that are too up-to-date
|
exclude group: 'net.minecraftforge', module: 'mergetool'
|
||||||
exclude module: 'launchwrapper'
|
|
||||||
exclude module: 'guava'
|
|
||||||
exclude module: 'gson'
|
|
||||||
exclude module: 'commons-io'
|
|
||||||
exclude module: 'log4j-core'
|
|
||||||
}
|
}
|
||||||
runtime launchCompile('dev.babbaj:nether-pathfinder:0.2')
|
}
|
||||||
|
|
||||||
|
// lwjgl2 hack for running game on arm64 mac os
|
||||||
|
afterEvaluate {
|
||||||
|
def os = org.gradle.internal.os.OperatingSystem.current()
|
||||||
|
if (os.isMacOsX()) {
|
||||||
|
def arch = System.getProperty("os.arch").toLowerCase()
|
||||||
|
println("Detected Mac OS X running on ${arch}")
|
||||||
|
if (arch == "aarch64") {
|
||||||
|
println("Configurating aarch64 dependencies.")
|
||||||
|
|
||||||
|
configurations.minecraft {
|
||||||
|
exclude group: 'ca.weblite', module: 'java-objc-bridge'
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// https://github.com/MinecraftMachina/lwjgl/releases/download/2.9.4-20150209-mmachina.2/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar
|
||||||
|
minecraft files("libs/lwjgl-platform-2.9.4-nightly-20150209-natives-osx.jar") // TODO: use prism launcher maven
|
||||||
|
// https://github.com/MinecraftMachina/Java-Objective-C-Bridge/releases/download/1.1.0-mmachina.1/java-objc-bridge-1.1.jar
|
||||||
|
minecraft files("libs/java-objc-bridge-1.1.jar") // TODO: use prism launcher maven
|
||||||
|
minecraft(group: 'net.java.dev.jna', name: 'jna') {
|
||||||
|
version {
|
||||||
|
strictly '5.12.1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
minecraft group: 'net.minecraft', name: 'joined', version: '1.12.2'
|
||||||
|
implementation(group: 'net.minecraft', name: 'launchwrapper', version: '1.12') {
|
||||||
|
transitive = false
|
||||||
|
}
|
||||||
|
|
||||||
|
def asmVersion = '9.5'
|
||||||
|
implementation group: 'org.ow2.asm', name: 'asm', version: asmVersion
|
||||||
|
implementation group: 'org.ow2.asm', name: 'asm-tree', version: asmVersion
|
||||||
|
implementation group: 'org.ow2.asm', name: 'asm-commons', version: asmVersion
|
||||||
|
implementation group: 'org.ow2.asm', name: 'asm-analysis', version: asmVersion
|
||||||
|
implementation group: 'org.ow2.asm', name: 'asm-util', version: asmVersion
|
||||||
|
|
||||||
|
launchImplementation('com.github.ImpactDevelopment:SimpleTweaker:1.2')
|
||||||
|
launchImplementation('org.spongepowered:mixin:0.7.11-SNAPSHOT') {
|
||||||
|
// Mixin includes a lot of dependencies that are too up-to-date
|
||||||
|
transitive = false
|
||||||
|
}
|
||||||
|
launchAnnotationProcessor 'org.spongepowered:mixin:0.8.4-SNAPSHOT:processor'
|
||||||
|
launchImplementation('dev.babbaj:nether-pathfinder:0.2')
|
||||||
testImplementation 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
implementation 'dev.babbaj:nether-pathfinder:0.2'
|
implementation 'dev.babbaj:nether-pathfinder:0.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
mixin {
|
mixin {
|
||||||
defaultObfuscationEnv searge
|
|
||||||
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
add sourceSets.launch, 'mixins.baritone.refmap.json'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +205,7 @@ jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes(
|
attributes(
|
||||||
'MixinConfigs': 'mixins.baritone.json',
|
'MixinConfigs': 'mixins.baritone.json',
|
||||||
|
'TweakClass': 'baritone.launch.BaritoneTweaker',
|
||||||
'Implementation-Title': 'Baritone',
|
'Implementation-Title': 'Baritone',
|
||||||
'Implementation-Version': version
|
'Implementation-Version': version
|
||||||
)
|
)
|
||||||
|
@ -152,25 +220,3 @@ task proguard(type: ProguardTask) {
|
||||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||||
|
|
||||||
build.finalizedBy(createDist)
|
build.finalizedBy(createDist)
|
||||||
|
|
||||||
install {
|
|
||||||
def jarApiName = String.format("%s-api-%s", rootProject.name, version.toString())
|
|
||||||
def jarApiForgeName = String.format("%s-api-forge-%s", rootProject.name, version.toString())
|
|
||||||
def jarSAName = String.format("%s-standalone-%s", rootProject.name, version.toString())
|
|
||||||
def jarSAForgeName = String.format("%s-standalone-forge-%s", rootProject.name, version.toString())
|
|
||||||
|
|
||||||
artifacts {
|
|
||||||
archives file("$buildDir/libs/" + jarApiName + ".jar")
|
|
||||||
archives file("$buildDir/libs/" + jarApiForgeName + ".jar")
|
|
||||||
archives file("$buildDir/libs/" + jarSAName + ".jar")
|
|
||||||
archives file("$buildDir/libs/" + jarSAForgeName + ".jar")
|
|
||||||
}
|
|
||||||
repositories.mavenInstaller {
|
|
||||||
addFilter('api') { artifact, file -> artifact.name == "baritone-api" }
|
|
||||||
addFilter('api-forge') { artifact, file -> artifact.name == "baritone-api-forge" }
|
|
||||||
addFilter('standalone') { artifact, file -> artifact.name == "baritone-standalone" }
|
|
||||||
addFilter('standalone-forge') { artifact, file -> artifact.name == "baritone-standalone-forge" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
install.dependsOn(build)
|
|
||||||
|
|
|
@ -20,6 +20,6 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.5'
|
||||||
compile group: 'commons-io', name: 'commons-io', version: '2.6'
|
implementation group: 'commons-io', name: 'commons-io', version: '2.6'
|
||||||
}
|
}
|
|
@ -18,39 +18,33 @@
|
||||||
package baritone.gradle.task;
|
package baritone.gradle.task;
|
||||||
|
|
||||||
import baritone.gradle.util.Determinizer;
|
import baritone.gradle.util.Determinizer;
|
||||||
import baritone.gradle.util.MappingType;
|
|
||||||
import baritone.gradle.util.ReobfWrapper;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.gradle.api.JavaVersion;
|
import org.gradle.api.Project;
|
||||||
import org.gradle.api.NamedDomainObjectContainer;
|
|
||||||
import org.gradle.api.artifacts.Configuration;
|
import org.gradle.api.artifacts.Configuration;
|
||||||
import org.gradle.api.artifacts.Dependency;
|
import org.gradle.api.artifacts.Dependency;
|
||||||
import org.gradle.api.internal.file.IdentityFileResolver;
|
|
||||||
import org.gradle.api.internal.plugins.DefaultConvention;
|
|
||||||
import org.gradle.api.tasks.Input;
|
import org.gradle.api.tasks.Input;
|
||||||
import org.gradle.api.tasks.TaskAction;
|
import org.gradle.api.tasks.TaskAction;
|
||||||
import org.gradle.api.tasks.TaskCollection;
|
import org.gradle.api.tasks.TaskCollection;
|
||||||
import org.gradle.api.tasks.compile.ForkOptions;
|
import org.gradle.api.tasks.compile.ForkOptions;
|
||||||
import org.gradle.api.tasks.compile.JavaCompile;
|
import org.gradle.api.tasks.compile.JavaCompile;
|
||||||
import org.gradle.internal.Pair;
|
|
||||||
import org.gradle.internal.jvm.Jvm;
|
import org.gradle.internal.jvm.Jvm;
|
||||||
import org.gradle.internal.jvm.inspection.DefaultJvmVersionDetector;
|
|
||||||
import org.gradle.process.internal.DefaultExecActionFactory;
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Brady
|
* @author Brady
|
||||||
* @since 10/11/2018
|
* @since 10/11/2018
|
||||||
|
@ -138,23 +132,16 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||||
|
|
||||||
private String findJavaByGradleCurrentRuntime() {
|
private String findJavaByGradleCurrentRuntime() {
|
||||||
String path = Jvm.current().getJavaExecutable().getAbsolutePath();
|
String path = Jvm.current().getJavaExecutable().getAbsolutePath();
|
||||||
|
System.out.println("Using Gradle's runtime Java for ProGuard");
|
||||||
if (this.validateJavaVersion(path)) {
|
return path;
|
||||||
System.out.println("Using Gradle's runtime Java for ProGuard");
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String findJavaByJavaHome() {
|
private String findJavaByJavaHome() {
|
||||||
final String javaHomeEnv = System.getenv("JAVA_HOME");
|
final String javaHomeEnv = System.getenv("JAVA_HOME");
|
||||||
if (javaHomeEnv != null) {
|
if (javaHomeEnv != null) {
|
||||||
|
|
||||||
String path = Jvm.forHome(new File(javaHomeEnv)).getJavaExecutable().getAbsolutePath();
|
String path = Jvm.forHome(new File(javaHomeEnv)).getJavaExecutable().getAbsolutePath();
|
||||||
if (this.validateJavaVersion(path)) {
|
System.out.println("Detected Java path by JAVA_HOME");
|
||||||
System.out.println("Detected Java path by JAVA_HOME");
|
return path;
|
||||||
return path;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -170,19 +157,11 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||||
if (javacPath != null) {
|
if (javacPath != null) {
|
||||||
File javacFile = new File(javacPath);
|
File javacFile = new File(javacPath);
|
||||||
if (javacFile.exists()) {
|
if (javacFile.exists()) {
|
||||||
File[] maybeJava = javacFile.getParentFile().listFiles(new FilenameFilter() {
|
File[] maybeJava = javacFile.getParentFile().listFiles((dir, name) -> name.equals("java"));
|
||||||
@Override
|
|
||||||
public boolean accept(File dir, String name) {
|
|
||||||
return name.equals("java");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (maybeJava != null && maybeJava.length > 0) {
|
if (maybeJava != null && maybeJava.length > 0) {
|
||||||
String path = maybeJava[0].getAbsolutePath();
|
String path = maybeJava[0].getAbsolutePath();
|
||||||
if (this.validateJavaVersion(path)) {
|
System.out.println("Detected Java path by forkOptions");
|
||||||
System.out.println("Detected Java path by forkOptions");
|
return path;
|
||||||
return path;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,21 +169,8 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateJavaVersion(String java) {
|
|
||||||
final JavaVersion javaVersion = new DefaultJvmVersionDetector(new DefaultExecActionFactory(new IdentityFileResolver())).getJavaVersion(java);
|
|
||||||
|
|
||||||
if (!javaVersion.getMajorVersion().equals("8")) {
|
|
||||||
System.out.println("Failed to validate Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
|
|
||||||
// throw new RuntimeException("Java version incorrect: " + javaVersion.getMajorVersion() + " for " + java);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("Validated Java version " + javaVersion.toString() + " [" + java + "] for ProGuard libraryjars");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void generateConfigs() throws Exception {
|
private void generateConfigs() throws Exception {
|
||||||
Files.copy(getRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), REPLACE_EXISTING);
|
Files.copy(getRelativeFile(PROGUARD_CONFIG_TEMPLATE), getTemporaryFile(PROGUARD_CONFIG_DEST), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
// Setup the template that will be used to derive the API and Standalone configs
|
// Setup the template that will be used to derive the API and Standalone configs
|
||||||
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
|
List<String> template = Files.readAllLines(getTemporaryFile(PROGUARD_CONFIG_DEST));
|
||||||
|
@ -236,14 +202,37 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void acquireDependencies() throws Exception {
|
private static final class Pair<A, B> {
|
||||||
|
public final A a;
|
||||||
|
public final B b;
|
||||||
|
|
||||||
|
private Pair(final A a, final B b) {
|
||||||
|
this.a = a;
|
||||||
|
this.b = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "Pair{" +
|
||||||
|
"a=" + this.a +
|
||||||
|
", " +
|
||||||
|
"b=" + this.b +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void acquireDependencies() throws Exception {
|
||||||
// Create a map of all of the dependencies that we are able to access in this project
|
// Create a map of all of the dependencies that we are able to access in this project
|
||||||
// Likely a better way to do this, I just pair the dependency with the first valid configuration
|
// Likely a better way to do this, I just pair the dependency with the first valid configuration
|
||||||
Map<String, Pair<Configuration, Dependency>> dependencyLookupMap = new HashMap<>();
|
Map<String, Pair<Configuration, Dependency>> dependencyLookupMap = new HashMap<>();
|
||||||
getProject().getConfigurations().stream().filter(Configuration::isCanBeResolved).forEach(config ->
|
Map<String, File> files = new HashMap<>();
|
||||||
config.getAllDependencies().forEach(dependency ->
|
getProject().getConfigurations().stream().filter(Configuration::isCanBeResolved).forEach(config -> {
|
||||||
dependencyLookupMap.putIfAbsent(dependency.getName() + "-" + dependency.getVersion(), Pair.of(config, dependency))));
|
for (File file : config.getFiles()) {
|
||||||
|
files.put(file.getName(), file);
|
||||||
|
}
|
||||||
|
config.getAllDependencies().forEach(dependency ->
|
||||||
|
dependencyLookupMap.putIfAbsent(dependency.getName() + "-" + dependency.getVersion(), new Pair<>(config, dependency)));
|
||||||
|
});
|
||||||
|
|
||||||
// Create the directory if it doesn't already exist
|
// Create the directory if it doesn't already exist
|
||||||
Path tempLibraries = getTemporaryFile(TEMP_LIBRARY_DIR);
|
Path tempLibraries = getTemporaryFile(TEMP_LIBRARY_DIR);
|
||||||
|
@ -258,7 +247,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||||
Path cachedJar = getMinecraftJar();
|
Path cachedJar = getMinecraftJar();
|
||||||
Path inTempDir = getTemporaryFile("tempLibraries/minecraft.jar");
|
Path inTempDir = getTemporaryFile("tempLibraries/minecraft.jar");
|
||||||
// TODO: maybe try not to copy every time
|
// TODO: maybe try not to copy every time
|
||||||
Files.copy(cachedJar, inTempDir, REPLACE_EXISTING);
|
Files.copy(cachedJar, inTempDir, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -270,20 +259,21 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||||
pair = entry.getValue();
|
pair = entry.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The pair must be non-null
|
|
||||||
Objects.requireNonNull(pair);
|
|
||||||
|
|
||||||
// Find the library jar file, and copy it to tempLibraries
|
// Find the library jar file, and copy it to tempLibraries
|
||||||
for (File file : pair.getLeft().files(pair.getRight())) {
|
if (pair == null) {
|
||||||
if (file.getName().startsWith(lib)) {
|
File libFile = files.get(lib + ".jar");
|
||||||
if (lib.contains("mixin")) {
|
if (libFile == null) {
|
||||||
mixin = file;
|
libFile = files.values().stream().filter(file -> file.getName().startsWith(lib)).findFirst().orElse(null);
|
||||||
|
if (libFile == null) {
|
||||||
|
throw new IllegalStateException(lib);
|
||||||
}
|
}
|
||||||
if (lib.contains("nether-pathfinder")) {
|
}
|
||||||
pathfinder = file;
|
copyTempLib(lib, libFile);
|
||||||
|
} else {
|
||||||
|
for (File file : pair.a.files(pair.b)) {
|
||||||
|
if (file.getName().startsWith(lib)) {
|
||||||
|
copyTempLib(lib, file);
|
||||||
}
|
}
|
||||||
Files.copy(file.toPath(), getTemporaryFile("tempLibraries/" + lib + ".jar"), REPLACE_EXISTING);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -295,87 +285,39 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void copyTempLib(String lib, File libFile) throws IOException {
|
||||||
|
if (lib.contains("mixin")) {
|
||||||
|
mixin = libFile;
|
||||||
|
}
|
||||||
|
if (lib.contains("nether-pathfinder")) {
|
||||||
|
pathfinder = libFile;
|
||||||
|
}
|
||||||
|
Files.copy(libFile.toPath(), getTemporaryFile("tempLibraries/" + lib + ".jar"), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
}
|
||||||
|
|
||||||
// a bunch of epic stuff to get the path to the cached jar
|
// a bunch of epic stuff to get the path to the cached jar
|
||||||
private Path getMinecraftJar() throws Exception {
|
private Path getMinecraftJar() throws Exception {
|
||||||
MappingType mappingType;
|
return getObfuscatedMinecraftJar(getProject(), false); // always notch jar for now.
|
||||||
try {
|
|
||||||
mappingType = getMappingType();
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Failed to get mapping type, assuming NOTCH.");
|
|
||||||
mappingType = MappingType.NOTCH;
|
|
||||||
}
|
|
||||||
|
|
||||||
String suffix;
|
|
||||||
switch (mappingType) {
|
|
||||||
case NOTCH:
|
|
||||||
suffix = "";
|
|
||||||
break;
|
|
||||||
case SEARGE:
|
|
||||||
suffix = "-srgBin";
|
|
||||||
break;
|
|
||||||
case CUSTOM:
|
|
||||||
throw new IllegalStateException("Custom mappings not supported!");
|
|
||||||
default:
|
|
||||||
throw new IllegalStateException("Unknown mapping type: " + mappingType);
|
|
||||||
}
|
|
||||||
|
|
||||||
DefaultConvention convention = (DefaultConvention) this.getProject().getConvention();
|
|
||||||
Object extension = convention.getAsMap().get("minecraft");
|
|
||||||
Objects.requireNonNull(extension);
|
|
||||||
|
|
||||||
// for some reason cant use Class.forName
|
|
||||||
Class<?> class_baseExtension = extension.getClass().getSuperclass().getSuperclass().getSuperclass(); // <-- cursed
|
|
||||||
Field f_replacer = class_baseExtension.getDeclaredField("replacer");
|
|
||||||
f_replacer.setAccessible(true);
|
|
||||||
Object replacer = f_replacer.get(extension);
|
|
||||||
Class<?> class_replacementProvider = replacer.getClass();
|
|
||||||
Field replacement_replaceMap = class_replacementProvider.getDeclaredField("replaceMap");
|
|
||||||
replacement_replaceMap.setAccessible(true);
|
|
||||||
|
|
||||||
Map<String, Object> replacements = (Map) replacement_replaceMap.get(replacer);
|
|
||||||
String cacheDir = replacements.get("CACHE_DIR").toString() + "/net/minecraft";
|
|
||||||
String mcVersion = replacements.get("MC_VERSION").toString();
|
|
||||||
String mcpInsert = replacements.get("MAPPING_CHANNEL").toString() + "/" + replacements.get("MAPPING_VERSION").toString();
|
|
||||||
String fullJarName = "minecraft-" + mcVersion + suffix + ".jar";
|
|
||||||
|
|
||||||
String baseDir = String.format("%s/minecraft/%s/", cacheDir, mcVersion);
|
|
||||||
|
|
||||||
String jarPath;
|
|
||||||
if (mappingType == MappingType.SEARGE) {
|
|
||||||
jarPath = String.format("%s/%s/%s", baseDir, mcpInsert, fullJarName);
|
|
||||||
} else {
|
|
||||||
jarPath = baseDir + fullJarName;
|
|
||||||
}
|
|
||||||
jarPath = jarPath
|
|
||||||
.replace("/", File.separator)
|
|
||||||
.replace("\\", File.separator); // hecking regex
|
|
||||||
|
|
||||||
return new File(jarPath).toPath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// throws IllegalStateException if mapping type is ambiguous or it fails to find it
|
private static Path getObfuscatedMinecraftJar(final Project project, final boolean srg) throws Exception {
|
||||||
private MappingType getMappingType() {
|
final Object extension = Objects.requireNonNull(project.getExtensions().findByName("minecraft"), "Unable to find Minecraft extension.");
|
||||||
// if it fails to find this then its probably a forgegradle version problem
|
|
||||||
Set<Object> reobf = (NamedDomainObjectContainer<Object>) this.getProject().getExtensions().getByName("reobf");
|
|
||||||
|
|
||||||
List<MappingType> mappingTypes = getUsedMappingTypes(reobf);
|
final Class<?> mcpRepoClass = mcpRepoClass(extension.getClass().getClassLoader());
|
||||||
long mappingTypesUsed = mappingTypes.size();
|
final Field mcpRepoInstanceField = mcpRepoClass.getDeclaredField("INSTANCE");
|
||||||
if (mappingTypesUsed == 0) {
|
mcpRepoInstanceField.setAccessible(true);
|
||||||
throw new IllegalStateException("Failed to find mapping type (no jar task?)");
|
final Method findMethod = mcpRepoClass.getDeclaredMethod(srg ? "findSrg" : "findRaw", String.class, String.class);
|
||||||
}
|
findMethod.setAccessible(true);
|
||||||
if (mappingTypesUsed > 1) {
|
|
||||||
throw new IllegalStateException("Ambiguous mapping type (multiple jars with different mapping types?)");
|
|
||||||
}
|
|
||||||
|
|
||||||
return mappingTypes.get(0);
|
final Object mcpRepo = mcpRepoInstanceField.get(null);
|
||||||
|
final String mcpVersion = (String) Objects.requireNonNull(project.getExtensions().getExtraProperties().get("MCP_VERSION"), "Extra property \"MCP_VERSION\" not found");
|
||||||
|
return ((File) findMethod.invoke(mcpRepo, "joined", mcpVersion)).toPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MappingType> getUsedMappingTypes(Set<Object> reobf) {
|
private static Class<?> mcpRepoClass(final ClassLoader loader) throws Exception {
|
||||||
return reobf.stream()
|
final Method forName0 = Class.class.getDeclaredMethod("forName0", String.class, boolean.class, ClassLoader.class, Class.class);
|
||||||
.map(ReobfWrapper::new)
|
forName0.setAccessible(true);
|
||||||
.map(ReobfWrapper::getMappingType)
|
return (Class<?>) forName0.invoke(null, "net.minecraftforge.gradle.mcp.MCPRepo", true, loader, null);
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void proguardApi() throws Exception {
|
private void proguardApi() throws Exception {
|
||||||
|
@ -400,10 +342,18 @@ public class ProguardTask extends BaritoneGradleTask {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
public void setExtract(String extract) {
|
public void setExtract(String extract) {
|
||||||
this.extract = extract;
|
this.extract = extract;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getExtract() {
|
||||||
|
return extract;
|
||||||
|
}
|
||||||
|
|
||||||
private void runProguard(Path config) throws Exception {
|
private void runProguard(Path config) throws Exception {
|
||||||
// Delete the existing proguard output file. Proguard probably handles this already, but why not do it ourselves
|
// Delete the existing proguard output file. Proguard probably handles this already, but why not do it ourselves
|
||||||
if (Files.exists(this.proguardOut)) {
|
if (Files.exists(this.proguardOut)) {
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.gradle.util;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All credits go to AsmLibGradle and its contributors.
|
|
||||||
*
|
|
||||||
* @see <a href="https://github.com/pozzed/AsmLibGradle/blob/8f917dbc3939eab7a3d9daf54d9d285fdf34f4b2/src/main/java/net/futureclient/asmlib/forgegradle/MappingType.java">Original Source</a>
|
|
||||||
*/
|
|
||||||
public enum MappingType {
|
|
||||||
SEARGE,
|
|
||||||
NOTCH,
|
|
||||||
CUSTOM // forgegradle
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package baritone.gradle.util;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All credits go to AsmLibGradle and its contributors.
|
|
||||||
*
|
|
||||||
* @see <a href="https://github.com/pozzed/AsmLibGradle/blob/8f917dbc3939eab7a3d9daf54d9d285fdf34f4b2/src/main/java/net/futureclient/asmlib/forgegradle/ReobfWrapper.java">Original Source</a>
|
|
||||||
*/
|
|
||||||
public class ReobfWrapper {
|
|
||||||
|
|
||||||
private final Object instance;
|
|
||||||
private final Class<?> type;
|
|
||||||
|
|
||||||
public ReobfWrapper(Object instance) {
|
|
||||||
this.instance = instance;
|
|
||||||
Objects.requireNonNull(instance);
|
|
||||||
this.type = instance.getClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
try {
|
|
||||||
Field nameField = type.getDeclaredField("name");
|
|
||||||
nameField.setAccessible(true);
|
|
||||||
return (String) nameField.get(this.instance);
|
|
||||||
} catch (ReflectiveOperationException ex) {
|
|
||||||
throw new IllegalStateException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MappingType getMappingType() {
|
|
||||||
try {
|
|
||||||
Field enumField = type.getDeclaredField("mappingType");
|
|
||||||
enumField.setAccessible(true);
|
|
||||||
Enum<?> aEnum = (Enum<?>) enumField.get(this.instance);
|
|
||||||
MappingType mappingType = MappingType.values()[aEnum.ordinal()];
|
|
||||||
if (!aEnum.name().equals(mappingType.name())) {
|
|
||||||
throw new IllegalStateException("ForgeGradle ReobfMappingType is not equivalent to MappingType (version error?)");
|
|
||||||
}
|
|
||||||
return mappingType;
|
|
||||||
} catch (ReflectiveOperationException ex) {
|
|
||||||
throw new IllegalStateException(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
|
@ -1,6 +1,5 @@
|
||||||
#Tue Jul 31 21:56:56 PDT 2018
|
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.4-all.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
|
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
##
|
||||||
## Gradle start up script for UN*X
|
## Gradle start up script for UN*X
|
||||||
|
@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS=""
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
|
@ -56,7 +72,7 @@ case "`uname`" in
|
||||||
Darwin* )
|
Darwin* )
|
||||||
darwin=true
|
darwin=true
|
||||||
;;
|
;;
|
||||||
MINGW* )
|
MSYS* | MINGW* )
|
||||||
msys=true
|
msys=true
|
||||||
;;
|
;;
|
||||||
NONSTOP* )
|
NONSTOP* )
|
||||||
|
@ -66,6 +82,7 @@ esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
@ -109,10 +126,11 @@ if $darwin; then
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if $cygwin ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
@ -138,19 +156,19 @@ if $cygwin ; then
|
||||||
else
|
else
|
||||||
eval `echo args$i`="\"$arg\""
|
eval `echo args$i`="\"$arg\""
|
||||||
fi
|
fi
|
||||||
i=$((i+1))
|
i=`expr $i + 1`
|
||||||
done
|
done
|
||||||
case $i in
|
case $i in
|
||||||
(0) set -- ;;
|
0) set -- ;;
|
||||||
(1) set -- "$args0" ;;
|
1) set -- "$args0" ;;
|
||||||
(2) set -- "$args0" "$args1" ;;
|
2) set -- "$args0" "$args1" ;;
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -159,14 +177,9 @@ save () {
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
echo " "
|
echo " "
|
||||||
}
|
}
|
||||||
APP_ARGS=$(save "$@")
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
|
@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS=
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
@ -35,7 +54,7 @@ goto fail
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
@ -45,28 +64,14 @@ echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
||||||
|
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
|
||||||
|
|
||||||
:win9xME_args_slurp
|
|
||||||
if "x%~1" == "x" goto execute
|
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|
|
@ -0,0 +1,161 @@
|
||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ext.doHackyStuff = { final Class<?> clazz ->
|
||||||
|
def withExtension = { final File file, final String extension ->
|
||||||
|
def i = file.getName().lastIndexOf('.')
|
||||||
|
def name = file.getName().substring(0, i)
|
||||||
|
return new File(file.getParent(), "$name.$extension")
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/patcher/java/net/minecraftforge/gradle/patcher/PatcherPlugin.java#L545
|
||||||
|
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/userdev/java/net/minecraftforge/gradle/userdev/UserDevPlugin.java#L149
|
||||||
|
// create createMcp2Obf task
|
||||||
|
this.tasks.register('createMcpToObf', clazz)
|
||||||
|
.configure { task ->
|
||||||
|
task.setNotch(true)
|
||||||
|
task.setReverse(true)
|
||||||
|
}
|
||||||
|
afterEvaluate {
|
||||||
|
def createMcp2Obf = this.tasks.getByName('createMcpToObf')
|
||||||
|
def createMcp2Srg = this.tasks.getByName('createMcpToSrg')
|
||||||
|
|
||||||
|
// configure createMcp2Obf task
|
||||||
|
if (createMcp2Obf.getSrg() == null) {
|
||||||
|
createMcp2Obf.setSrg(createMcp2Srg.getSrg())
|
||||||
|
createMcp2Obf.setMappings(createMcp2Srg.getMappings())
|
||||||
|
createMcp2Obf.dependsOn(createMcp2Srg)
|
||||||
|
}
|
||||||
|
|
||||||
|
def createSrgCopyTask = { final Task tsrgTask ->
|
||||||
|
def srgCopyTask = this.tasks.register("${tsrgTask.name}Srg", tsrgTask.getClass())
|
||||||
|
tsrgTask.getDependsOn().forEach({ dep ->
|
||||||
|
srgCopyTask.get().dependsOn(dep)
|
||||||
|
})
|
||||||
|
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/mcp/java/net/minecraftforge/gradle/mcp/task/GenerateSRG.java#L39
|
||||||
|
srgCopyTask.configure { task ->
|
||||||
|
task.setSrg(tsrgTask.getSrg())
|
||||||
|
task.setMappings(tsrgTask.getMappings())
|
||||||
|
// https://github.com/MinecraftForge/SrgUtils/blob/bb2ca35bb8d349a122ef512dedd24f54f7cd0bdf/src/main/java/net/minecraftforge/srgutils/IMappingFile.java#L44
|
||||||
|
task.setFormat('SRG')
|
||||||
|
task.setNotch(tsrgTask.getNotch())
|
||||||
|
task.setReverse(tsrgTask.getReverse())
|
||||||
|
task.setOutput(withExtension(tsrgTask.getOutput(), 'srg'))
|
||||||
|
}
|
||||||
|
return srgCopyTask
|
||||||
|
}
|
||||||
|
def createMcp2ObfSrgCopyTask = createSrgCopyTask(createMcp2Obf)
|
||||||
|
createMcp2Obf.dependsOn(createMcp2ObfSrgCopyTask)
|
||||||
|
def createMcp2SrgSrgCopyTask = createSrgCopyTask(createMcp2Srg)
|
||||||
|
createMcp2Srg.dependsOn(createMcp2SrgSrgCopyTask)
|
||||||
|
|
||||||
|
this.sourceSets.forEach({ set ->
|
||||||
|
def compileTask = this.project.tasks[set.compileJavaTaskName]
|
||||||
|
if (!(compileTask instanceof JavaCompile)) {
|
||||||
|
println("[Baritoe] Non-java compile task for ${set} of type ${compileTask}")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
compileTask.dependsOn(createMcp2Obf)
|
||||||
|
compileTask.doFirst {
|
||||||
|
// inject legacy notch srg file
|
||||||
|
def createMcp2ObfSrgCopy = createMcp2ObfSrgCopyTask.get()
|
||||||
|
def reobfNotchSrgFileArgument = "-AreobfNotchSrgFile=${createMcp2ObfSrgCopy.output.canonicalPath}"
|
||||||
|
compileTask.options.compilerArgs += reobfNotchSrgFileArgument
|
||||||
|
println("[Baritoe] Injecting compiler argument: ${reobfNotchSrgFileArgument}")
|
||||||
|
|
||||||
|
// inject legacy notch srg out file
|
||||||
|
def outTSrgFileArgument = '-AoutTsrgFile='
|
||||||
|
def compilerArgsIterator = compileTask.options.compilerArgs.listIterator()
|
||||||
|
while (compilerArgsIterator.hasNext()) {
|
||||||
|
def compilerArg = compilerArgsIterator.next()
|
||||||
|
if (compilerArg.startsWith(outTSrgFileArgument)) {
|
||||||
|
def argumentFileValue = new File(compilerArg.substring(outTSrgFileArgument.length(), compilerArg.length()))
|
||||||
|
def outNotchSrgFile = withExtension(argumentFileValue, 'notch.srg')
|
||||||
|
def outNotchSrgFileArgument = "-AoutNotchSrgFile=${outNotchSrgFile.canonicalPath}"
|
||||||
|
println("[Baritoe] Injecting compiler argument: ${outNotchSrgFileArgument}")
|
||||||
|
compilerArgsIterator.add(outNotchSrgFileArgument)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// register reobf jars
|
||||||
|
def reobfExtension = this.project.getExtensions().getByName('reobf')
|
||||||
|
if (!reobfExtension) {
|
||||||
|
throw new IllegalStateException("Could not find \"reobf\" extension")
|
||||||
|
}
|
||||||
|
def reobfNotchJar = reobfExtension.create(jar.getName())
|
||||||
|
reobfNotchJar.dependsOn(createMcp2Obf)
|
||||||
|
reobfNotchJar.setMappings(createMcp2Obf.getOutput())
|
||||||
|
|
||||||
|
// even more horrible hack :) for outNotchSrgFile injection
|
||||||
|
reobfNotchJar.doFirst {
|
||||||
|
// https://github.com/MinecraftForge/ForgeGradle/blob/6639464b29b0923187eee0a609e546ba9f1b998b/src/userdev/java/net/minecraftforge/gradle/userdev/tasks/RenameJar.java#L96
|
||||||
|
def extraMappings = reobfNotchJar.getExtraMappings()
|
||||||
|
println("[Baritoe] Extra mappings: ${extraMappings}")
|
||||||
|
def copy = new ArrayList<>()
|
||||||
|
extraMappings.forEach { extraMapping ->
|
||||||
|
copy.add(withExtension(extraMapping, 'notch.srg'))
|
||||||
|
}
|
||||||
|
println("[Baritoe] New extra mappings: ${copy}")
|
||||||
|
reobfNotchJar.setExtraMappings(copy)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: In-complete fg 5.0 port. Currently doesn't handle mixin notch srg mapping hack.
|
||||||
|
//ext.doHackyStuff = { final Class<?> clazz ->
|
||||||
|
// afterEvaluate {
|
||||||
|
// def createMcp2Srg = this.tasks.getByName('createMcpToSrg')
|
||||||
|
// def createMcpToObf = this.tasks.register('createMcpToObf', clazz)
|
||||||
|
// createMcpToObf.configure { task ->
|
||||||
|
// task.setNotch(true)
|
||||||
|
// task.setReverse(true)
|
||||||
|
// task.getSrg().set(createMcp2Srg.getSrg().get())
|
||||||
|
// task.getMappings().set(createMcp2Srg.getMappings().get())
|
||||||
|
// task.dependsOn(createMcp2Srg)
|
||||||
|
// }
|
||||||
|
// reobf {
|
||||||
|
// jar {
|
||||||
|
// dependsOn(createMcpToObf)
|
||||||
|
// getMappings().set(createMcpToObf.get().getOutput().get())
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// this.sourceSets.forEach({ set ->
|
||||||
|
// def compileTask = this.project.tasks[set.compileJavaTaskName]
|
||||||
|
// if (!(compileTask instanceof JavaCompile)) {
|
||||||
|
// println("[Baritoe] Non-java compile task for ${set} of type ${compileTask}")
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
// compileTask.dependsOn(createMcpToObf)
|
||||||
|
// compileTask.doFirst {
|
||||||
|
// def reobfTSrgFile = '-AreobfTsrgFile='
|
||||||
|
// def compilerArgsIterator = compileTask.options.compilerArgs.listIterator()
|
||||||
|
// while (compilerArgsIterator.hasNext()) {
|
||||||
|
// def compilerArg = compilerArgsIterator.next()
|
||||||
|
// if (compilerArg.startsWith(reobfTSrgFile)) {
|
||||||
|
// compilerArgsIterator.remove()
|
||||||
|
// def toInject = "-AreobfTsrgFile=${createMcpToObf.get().output.get().asFile.canonicalPath}"
|
||||||
|
// compilerArgsIterator.add(toInject)
|
||||||
|
// println("[Baritoe] Injecting compiler argument: ${toInject}")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// println("[Baritoe] Compiler arguments: ${compileTask.options.compilerArgs}")
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
//}
|
|
@ -92,7 +92,7 @@
|
||||||
-libraryjars 'tempLibraries/text2speech-1.10.3.jar'
|
-libraryjars 'tempLibraries/text2speech-1.10.3.jar'
|
||||||
|
|
||||||
-libraryjars 'tempLibraries/mixin-0.7.11-SNAPSHOT.jar'
|
-libraryjars 'tempLibraries/mixin-0.7.11-SNAPSHOT.jar'
|
||||||
-libraryjars 'tempLibraries/launchwrapper-1.11.jar' # TODO why does only 1.11.jar exist?
|
-libraryjars 'tempLibraries/launchwrapper-1.12.jar'
|
||||||
|
|
||||||
-libraryjars 'tempLibraries/nether-pathfinder-.jar'
|
-libraryjars 'tempLibraries/nether-pathfinder-.jar'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue