mirror of https://github.com/cabaletta/baritone
proguard builds now
This commit is contained in:
parent
48b34bfbb8
commit
394b4fd5b8
|
@ -25,12 +25,6 @@ jobs:
|
|||
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Build (fabric) with Gradle
|
||||
run: ./gradlew build -Pbaritone.fabric_build
|
||||
|
||||
- name: Build (forge) with Gradle
|
||||
run: ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
|
||||
|
||||
- name: Archive Artifacts
|
||||
uses: actions/upload-artifact@v2
|
||||
|
|
|
@ -13,5 +13,3 @@ COPY . /code
|
|||
WORKDIR /code
|
||||
|
||||
RUN ./gradlew build
|
||||
RUN ./gradlew build -Pbaritone.forge_build -Ploom.platform=forge
|
||||
RUN ./gradlew build -Pbaritone.fabric_build
|
||||
|
|
|
@ -36,6 +36,7 @@ class BaritoneGradleTask extends DefaultTask {
|
|||
protected static final String
|
||||
PROGUARD_ZIP = "proguard.zip",
|
||||
PROGUARD_JAR = "proguard.jar",
|
||||
MIXIN_JAR = "mixin.jar",
|
||||
PROGUARD_CONFIG_TEMPLATE = "scripts/proguard.pro",
|
||||
PROGUARD_CONFIG_DEST = "template.pro",
|
||||
PROGUARD_API_CONFIG = "api.pro",
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.gradle.api.tasks.compile.JavaCompile;
|
|||
import org.gradle.internal.jvm.Jvm;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
@ -52,6 +53,13 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||
return url;
|
||||
}
|
||||
|
||||
@Input
|
||||
private String mixinUrl;
|
||||
|
||||
public String getMixinUrl() {
|
||||
return mixinUrl;
|
||||
}
|
||||
|
||||
@Input
|
||||
private String extract;
|
||||
|
||||
|
@ -66,15 +74,10 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||
return compType;
|
||||
}
|
||||
|
||||
private final File copyMcTargetDir = new File("./build/createMcIntermediaryJar").getAbsoluteFile();
|
||||
private final File copyMcTargetJar = new File(copyMcTargetDir, "client.jar");
|
||||
|
||||
@TaskAction
|
||||
protected void exec() throws Exception {
|
||||
super.verifyArtifacts();
|
||||
|
||||
copyMcJar();
|
||||
|
||||
// "Haha brady why don't you make separate tasks"
|
||||
processArtifact();
|
||||
downloadProguard();
|
||||
|
@ -89,7 +92,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||
return f.getName().startsWith(compType.equals("FORGE") ? "forge-" : "minecraft-") && f.getName().contains("minecraft-merged-named");
|
||||
}
|
||||
|
||||
private void copyMcJar() throws IOException {
|
||||
private File getMcJar() throws IOException {
|
||||
File mcClientJar = this.getProject().getConvention().getPlugin(JavaPluginConvention.class).getSourceSets().findByName("main").getRuntimeClasspath().getFiles()
|
||||
.stream()
|
||||
.filter(this::isMcJar)
|
||||
|
@ -107,8 +110,7 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||
.findFirst()
|
||||
.get();
|
||||
if (!mcClientJar.exists()) throw new IOException("Failed to find minecraft! " + mcClientJar.getAbsolutePath());
|
||||
if (!copyMcTargetDir.exists() && !copyMcTargetDir.mkdirs()) throw new IOException("Failed to create target for copyMcJar");
|
||||
Files.copy(mcClientJar.toPath(), copyMcTargetJar.toPath(), REPLACE_EXISTING);
|
||||
return mcClientJar;
|
||||
}
|
||||
|
||||
private void processArtifact() throws Exception {
|
||||
|
@ -136,6 +138,13 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||
}
|
||||
}
|
||||
|
||||
private void downloadMixin() throws Exception {
|
||||
Path mixinJar = getTemporaryFile(MIXIN_JAR);
|
||||
if (!Files.exists(mixinJar)) {
|
||||
write(new URL(this.mixinUrl).openStream(), mixinJar);
|
||||
}
|
||||
}
|
||||
|
||||
private String getJavaBinPathForProguard() throws Exception {
|
||||
String path;
|
||||
try {
|
||||
|
@ -245,6 +254,13 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||
|
||||
{
|
||||
final Stream<File> libraries;
|
||||
File mcJar;
|
||||
try {
|
||||
mcJar = getMcJar();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to find Minecraft jar", e);
|
||||
}
|
||||
|
||||
{
|
||||
// Discover all of the libraries that we will need to acquire from gradle
|
||||
final Stream<File> dependencies = acquireDependencies()
|
||||
|
@ -252,11 +268,14 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||
.filter(f -> !f.toString().endsWith("-recomp.jar") && !f.getName().startsWith("nashorn") && !f.getName().startsWith("coremods"));
|
||||
|
||||
libraries = dependencies
|
||||
.map(f -> isMcJar(f) ? copyMcTargetJar : f);
|
||||
.map(f -> isMcJar(f) ? mcJar : f);
|
||||
}
|
||||
libraries.forEach(f -> {
|
||||
template.add(2, "-libraryjars '" + f + "'");
|
||||
});
|
||||
|
||||
downloadMixin();
|
||||
template.add(2, "-libraryjars '" + this.getTemporaryFile(MIXIN_JAR) + "'");
|
||||
}
|
||||
|
||||
// API config doesn't require any changes from the changes that we made to the template
|
||||
|
@ -294,6 +313,10 @@ public class ProguardTask extends BaritoneGradleTask {
|
|||
this.url = url;
|
||||
}
|
||||
|
||||
public void setMixinUrl(String mixinUrl) {
|
||||
this.mixinUrl = mixinUrl;
|
||||
}
|
||||
|
||||
public void setExtract(String extract) {
|
||||
this.extract = extract;
|
||||
}
|
||||
|
|
|
@ -128,19 +128,17 @@ jar {
|
|||
}
|
||||
}
|
||||
|
||||
import net.fabricmc.loom.task.RemapJarTask
|
||||
|
||||
task transformProductionTweakerTask(type: RemapJarTask, dependsOn: jar) {
|
||||
input = project.tasks.getByName("jar").archiveFile
|
||||
archiveClassifier = "transformProductionTweaker"
|
||||
targetNamespace = "official"
|
||||
|
||||
remapJar {
|
||||
targetNamespace = 'official'
|
||||
}
|
||||
|
||||
jar.finalizedBy(transformProductionTweakerTask)
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
|
||||
mixinUrl 'https://maven.fabricmc.net/net/fabricmc/sponge-mixin/0.11.3%2Bmixin.0.8.5/sponge-mixin-0.11.3%2Bmixin.0.8.5.jar'
|
||||
extract 'proguard-7.2.1/lib/proguard.jar'
|
||||
compType "OFFICIAL"
|
||||
}
|
||||
|
||||
artifacts {
|
||||
transformProductionTweaker(transformProductionTweakerTask.archiveFile) {
|
||||
builtBy(transformProductionTweakerTask)
|
||||
}
|
||||
}
|
||||
task createDist(type: CreateDistTask, dependsOn: proguard)
|
||||
|
||||
build.finalizedBy(createDist)
|
||||
|
|
|
@ -40,7 +40,14 @@ configurations {
|
|||
dependencies {
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.fabric_version}"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements"))
|
||||
// this makes it compile with the forge tweak stuff
|
||||
implementation 'com.github.ImpactDevelopment:SimpleTweaker:1.2'
|
||||
implementation('net.minecraft:launchwrapper:1.12') {
|
||||
exclude module: 'lwjgl'
|
||||
exclude module: 'asm-debug-all'
|
||||
}
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
||||
}
|
||||
|
||||
|
@ -75,6 +82,7 @@ components.java {
|
|||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
|
||||
mixinUrl 'https://maven.fabricmc.net/net/fabricmc/sponge-mixin/0.11.3%2Bmixin.0.8.5/sponge-mixin-0.11.3%2Bmixin.0.8.5.jar'
|
||||
extract 'proguard-7.2.1/lib/proguard.jar'
|
||||
compType "FABRIC"
|
||||
}
|
||||
|
|
|
@ -46,9 +46,14 @@ configurations {
|
|||
dependencies {
|
||||
forge "net.minecraftforge:forge:${rootProject.forge_version}"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) {
|
||||
exclude module: "fabric-loader"
|
||||
}
|
||||
// this makes it compile with the forge tweak stuff
|
||||
implementation 'com.github.ImpactDevelopment:SimpleTweaker:1.2'
|
||||
implementation('net.minecraft:launchwrapper:1.12') {
|
||||
exclude module: 'lwjgl'
|
||||
exclude module: 'asm-debug-all'
|
||||
}
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive false }
|
||||
}
|
||||
|
||||
|
@ -95,6 +100,7 @@ components.java {
|
|||
|
||||
task proguard(type: ProguardTask) {
|
||||
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
|
||||
mixinUrl 'https://maven.fabricmc.net/net/fabricmc/sponge-mixin/0.11.3%2Bmixin.0.8.5/sponge-mixin-0.11.3%2Bmixin.0.8.5.jar'
|
||||
extract 'proguard-7.2.1/lib/proguard.jar'
|
||||
compType "FORGE"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue