fix dist names to match previous versions

This commit is contained in:
Wagyourtail 2023-02-18 16:59:39 -07:00
parent 7b60943714
commit 787644181a
No known key found for this signature in database
GPG Key ID: 0D30679891BED858
6 changed files with 44 additions and 24 deletions

View File

@ -19,6 +19,8 @@ package baritone.gradle.task;
import org.gradle.api.DefaultTask; import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Input;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.TaskAction;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -49,14 +51,35 @@ class BaritoneGradleTask extends DefaultTask {
ARTIFACT_STANDALONE = "%s-standalone-%s.jar"; ARTIFACT_STANDALONE = "%s-standalone-%s.jar";
protected String artifactName, artifactVersion; protected String artifactName, artifactVersion;
protected final Path protected Path
artifactPath, artifactPath,
artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, // these are different for forge builds artifactUnoptimizedPath, artifactApiPath, artifactStandalonePath, // these are different for forge builds
proguardOut; proguardOut;
@Input
@Optional
protected String compType = null;
public String getCompType() {
return compType;
}
public void setCompType(String compType) {
this.compType = compType;
}
public BaritoneGradleTask() { public BaritoneGradleTask() {
this.artifactName = getProject().getProperties().get("archivesBaseName").toString(); this.artifactName = getProject().getRootProject().getProperties().get("archives_base_name").toString();
}
public void doFirst() {
if (compType != null) {
this.artifactVersion = compType + "-" + getProject().getVersion();
} else {
this.artifactVersion = getProject().getVersion().toString(); this.artifactVersion = getProject().getVersion().toString();
}
this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD)); this.artifactPath = this.getBuildFile(formatVersion(ARTIFACT_STANDARD));
@ -99,4 +122,8 @@ class BaritoneGradleTask extends DefaultTask {
protected Path getBuildFile(String file) { protected Path getBuildFile(String file) {
return getRelativeFile("libs/" + file); return getRelativeFile("libs/" + file);
} }
protected String addCompTypeFirst(String string) {
return compType == null ? string : compType + "-" + string;
}
} }

View File

@ -41,6 +41,7 @@ public class CreateDistTask extends BaritoneGradleTask {
@TaskAction @TaskAction
protected void exec() throws Exception { protected void exec() throws Exception {
super.doFirst();
super.verifyArtifacts(); super.verifyArtifacts();
// Define the distribution file paths // Define the distribution file paths

View File

@ -63,15 +63,9 @@ public class ProguardTask extends BaritoneGradleTask {
return extract; return extract;
} }
@Input
private String compType;
public String getCompType() {
return compType;
}
@TaskAction @TaskAction
protected void exec() throws Exception { protected void exec() throws Exception {
super.doFirst();
super.verifyArtifacts(); super.verifyArtifacts();
// "Haha brady why don't you make separate tasks" // "Haha brady why don't you make separate tasks"
@ -253,7 +247,7 @@ public class ProguardTask extends BaritoneGradleTask {
Files.createDirectories(this.getRootRelativeFile(PROGUARD_MAPPING_DIR)); Files.createDirectories(this.getRootRelativeFile(PROGUARD_MAPPING_DIR));
List<String> api = new ArrayList<>(template); List<String> api = new ArrayList<>(template);
api.add(2, "-printmapping " + new File(this.getRootRelativeFile(PROGUARD_MAPPING_DIR).toFile(), "mappings-" + compType + "-api.txt")); api.add(2, "-printmapping " + new File(this.getRootRelativeFile(PROGUARD_MAPPING_DIR).toFile(), "mappings-" + addCompTypeFirst("api.txt")));
// API config doesn't require any changes from the changes that we made to the template // API config doesn't require any changes from the changes that we made to the template
Files.write(getTemporaryFile(compType+PROGUARD_API_CONFIG), api); Files.write(getTemporaryFile(compType+PROGUARD_API_CONFIG), api);
@ -261,7 +255,7 @@ public class ProguardTask extends BaritoneGradleTask {
// For the Standalone config, don't keep the API package // For the Standalone config, don't keep the API package
List<String> standalone = new ArrayList<>(template); List<String> standalone = new ArrayList<>(template);
standalone.removeIf(s -> s.contains("# this is the keep api")); standalone.removeIf(s -> s.contains("# this is the keep api"));
standalone.add(2, "-printmapping " + new File(this.getRootRelativeFile(PROGUARD_MAPPING_DIR).toFile(), "mappings-" + compType + "-standalone.txt")); standalone.add(2, "-printmapping " + new File(this.getRootRelativeFile(PROGUARD_MAPPING_DIR).toFile(), "mappings-" + addCompTypeFirst("standalone.txt")));
Files.write(getTemporaryFile(compType+PROGUARD_STANDALONE_CONFIG), standalone); Files.write(getTemporaryFile(compType+PROGUARD_STANDALONE_CONFIG), standalone);
} }
@ -294,11 +288,6 @@ public class ProguardTask extends BaritoneGradleTask {
public void setExtract(String extract) { public void setExtract(String extract) {
this.extract = extract; this.extract = extract;
} }
public void setCompType(String compType) {
this.compType = compType;
}
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)) {

View File

@ -22,7 +22,7 @@ plugins {
id "com.github.johnrengelman.shadow" version "7.0.0" id "com.github.johnrengelman.shadow" version "7.0.0"
} }
archivesBaseName = archivesBaseName + "-" + project.name archivesBaseName = archivesBaseName + "-fabric"
minecraft { minecraft {
fabric() fabric()
@ -79,10 +79,12 @@ components.java {
task proguard(type: ProguardTask) { task proguard(type: ProguardTask) {
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip' url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
extract 'proguard-7.2.1/lib/proguard.jar' extract 'proguard-7.2.1/lib/proguard.jar'
compType "FABRIC" compType "fabric"
} }
task createDist(type: CreateDistTask, dependsOn: proguard) task createDist(type: CreateDistTask, dependsOn: proguard) {
compType "fabric"
}
build.finalizedBy(createDist) build.finalizedBy(createDist)

View File

@ -22,7 +22,7 @@ plugins {
id "com.github.johnrengelman.shadow" version "7.0.0" id "com.github.johnrengelman.shadow" version "7.0.0"
} }
archivesBaseName = archivesBaseName + "-" + project.name archivesBaseName = archivesBaseName + "-forge"
minecraft { minecraft {
forge { forge {
@ -98,10 +98,12 @@ components.java {
task proguard(type: ProguardTask) { task proguard(type: ProguardTask) {
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip' url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
extract 'proguard-7.2.1/lib/proguard.jar' extract 'proguard-7.2.1/lib/proguard.jar'
compType "FORGE" compType "forge"
} }
task createDist(type: CreateDistTask, dependsOn: proguard) task createDist(type: CreateDistTask, dependsOn: proguard) {
compType "forge"
}
build.finalizedBy(createDist) build.finalizedBy(createDist)

View File

@ -97,7 +97,6 @@ jar {
task proguard(type: ProguardTask) { task proguard(type: ProguardTask) {
url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip' url 'https://github.com/Guardsquare/proguard/releases/download/v7.2.1/proguard-7.2.1.zip'
extract 'proguard-7.2.1/lib/proguard.jar' extract 'proguard-7.2.1/lib/proguard.jar'
compType "OFFICIAL"
} }
task createDist(type: CreateDistTask, dependsOn: proguard) task createDist(type: CreateDistTask, dependsOn: proguard)