Move fat jar build step to gradle build file

This commit is contained in:
artdeell
2022-05-09 18:38:05 +03:00
parent 3888ddf2e1
commit ab0ff09950
15 changed files with 8 additions and 36 deletions

View File

Binary file not shown.

View File

@@ -1 +1 @@
1652063179136
1652110329813

View File

@@ -267,40 +267,6 @@ public class PojavLoginActivity extends BaseActivity {
PojavProfile.setCurrentProfile(this, null);
}
private void repackLWJGL3(boolean ignoreExistence) throws IOException {
File outFile = new File(Tools.DIR_GAME_HOME + "/lwjgl3/lwjgl-fat.jar");
File outTmpFile = new File(Tools.DIR_GAME_HOME + "/lwjgl3/lwjgl-fat.jar.tmp");
File[] innerFiles = outTmpFile.getParentFile().listFiles();
if (outFile.exists() && !ignoreExistence) {
return;
}
outFile.delete();
outTmpFile.delete();
java.util.jar.Manifest manifest = new java.util.jar.Manifest();
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
JarOutputStream outJar = new JarOutputStream(new FileOutputStream(outTmpFile), manifest);
outJar.setLevel(9);
for (File file : innerFiles) {
if (!file.getName().endsWith(".jar")) continue;
JarInputStream inJar = new JarInputStream(new FileInputStream(file));
JarEntry entry;
while ((entry = inJar.getNextJarEntry()) != null) {
// avoid some duplicated entries
if (entry.getSize() == 0 || entry.getName().equals("META-INF/INDEX.LIST") || entry.getName().startsWith("META-INF/versions")) continue;
outJar.putNextEntry(new JarEntry(entry.getName()));
IOUtils.copy(inJar, outJar);
}
inJar.close();
file.delete();
}
outJar.close();
outTmpFile.renameTo(outFile);
}
private boolean unpackComponent(AssetManager am, String component) throws IOException {
File versionFile = new File(Tools.DIR_GAME_HOME + "/" + component + "/version");
InputStream is = am.open("components/" + component + "/version");
@@ -384,7 +350,7 @@ public class PojavLoginActivity extends BaseActivity {
// Since the Java module system doesn't allow multiple JARs to declare the same module,
// we repack them to a single file here
repackLWJGL3(unpackComponent(am, "lwjgl3"));
unpackComponent(am, "lwjgl3");
if(!installRuntimeAutomatically(am,MultiRTUtils.getRuntimes().size() > 0)) {
MultiRTConfigDialog.openRuntimeSelector(this, MultiRTConfigDialog.MULTIRT_PICK_RUNTIME_STARTUP);

View File

@@ -14,6 +14,12 @@ jar {
// Auto update the version with a timestamp so the project jar gets updated by Pojav
File versionFile = file("../app_pojavlauncher/src/main/assets/components/lwjgl3/version")
versionFile.write(String.valueOf(new Date().getTime()))
from {
configurations.default.collect {
println(it.getName())
it.isDirectory() ? it : zipTree(it)
}
}
}
java {

View File

Binary file not shown.

View File

Binary file not shown.

View File

Binary file not shown.