1.0.2
FreshCoffee/pipeline/head This commit looks good Details

This commit is contained in:
TheBrokenRail 2020-08-23 16:35:51 -04:00
parent ae5e9fe74c
commit 2020b895b9
8 changed files with 38 additions and 10 deletions

View File

@ -1,5 +1,8 @@
# Changelog
**1.0.2**
* Fix 32-Bit OpenJDk Installation
**1.0.1**
* Add Wrapping To Conflict Dialog

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
fabric_loader_version = 0.9.0+build.204
# Mod Properties
mod_version = 1.0.1
mod_version = 1.0.2
maven_group = com.thebrokenrail
# Dependencies

View File

@ -44,8 +44,7 @@ public class FreshCoffee implements PreLaunchEntrypoint {
File dir = Util.getJavaDir(jdk.version.semver);
if (dir.exists()) {
Util.getLogger().info("Removing Invalid Java Installation: " + dir.getAbsolutePath());
Util.deleteDirectory(dir);
Util.removeInvalidJDK(dir);
}
ExtractUtil.extract(url, dir);

View File

@ -16,6 +16,7 @@ public final class HardcodedConfig {
public static final String LIMIT_TEXT = "version %s required by %s";
public static final String JAVA_IMPLEMENTATION = "hotspot";
public static final String HEAP_SIZE = "normal";
public static final String OUTDATED_JAVA_MESSAGE = "An installed mod requires a newer version of Java (%s).";
public static final String OUTDATED_JAVA_WITH_OFFER_MESSAGE = OUTDATED_JAVA_MESSAGE + " Would you like to install it?\n%s will be downloaded.";

View File

@ -31,7 +31,7 @@ public final class AdoptOpenJDK {
private String project;
private boolean isValid() {
return heap_size.equals("normal") && image_type.equals("jre") && project.equals("jdk") && (packageObj.link.endsWith(".zip") || packageObj.link.endsWith(".tar.gz"));
return heap_size.equals(HardcodedConfig.HEAP_SIZE) && image_type.equals("jre") && project.equals("jdk") && (packageObj.link.endsWith(".zip") || packageObj.link.endsWith(".tar.gz"));
}
}
@ -85,7 +85,7 @@ public final class AdoptOpenJDK {
}
private static final String[] PLATFORM_TYPES = new String[]{"linux", "win", "macosx"};
private static final String[] ARCHITECTURE_TYPES = new String[]{"x64", "i686", "aarch64", "arm32"};
private static final String[] ARCHITECTURE_TYPES = new String[]{"x64", "x32", "aarch64", "arm"};
private static final Platform[] PLATFORMS;

View File

@ -22,13 +22,13 @@ public final class PlatformUtil {
case "x86":
case "i386":
case "i686": {
return "i686";
return "x32";
}
case "amd64": {
return "x64";
}
case "arm": {
return "arm32";
return "arm";
}
case "aarch64_be":
case "armv8b":

View File

@ -110,6 +110,23 @@ public final class ReLaunchUtil {
}
}
private static boolean testJavaBinary(String javaBinary) {
Process process;
try {
process = new ProcessBuilder(javaBinary, "-version").start();
} catch (IOException e) {
return false;
}
try {
int status = process.waitFor();
return status == 0;
} catch (InterruptedException e) {
process.destroy();
return false;
}
}
public static void reLaunch() {
File[] files = HardcodedConfig.INSTALL_DIR.listFiles();
if (files != null) {
@ -123,10 +140,13 @@ public final class ReLaunchUtil {
String newestVersion = JavaVersionUtil.getNewest(list.toArray(new String[0]));
if (newestVersion != null) {
File javaBinary = new File(new File(Util.getJavaDir(newestVersion), "bin"), "java" + PlatformUtil.getExecutableExtension());
if (javaBinary.exists() && javaBinary.canExecute()) {
File javaDir = Util.getJavaDir(newestVersion);
File javaBinary = new File(new File(javaDir, "bin"), "java" + PlatformUtil.getExecutableExtension());
if (javaBinary.exists() && javaBinary.canExecute() && testJavaBinary(javaBinary.getAbsolutePath())) {
Util.getLogger().info("Using Java Executable: " + javaBinary.getAbsolutePath());
reLaunch(javaBinary.getAbsolutePath());
} else {
Util.removeInvalidJDK(javaDir);
}
}
}

View File

@ -27,7 +27,7 @@ public final class Util {
return new File(HardcodedConfig.INSTALL_DIR, version);
}
public static void deleteDirectory(File directoryToBeDeleted) {
private static void deleteDirectory(File directoryToBeDeleted) {
File[] allContents = directoryToBeDeleted.listFiles();
if (allContents != null) {
for (File file : allContents) {
@ -66,4 +66,9 @@ public final class Util {
String pre = (si ? "kMGTPE" : "KMGTPE").charAt(exp - 1) + (si ? "" : "i");
return String.format("%.1f %sB", bytes / Math.pow(unit, exp), pre);
}
public static void removeInvalidJDK(File dir) {
Util.getLogger().info("Removing Invalid Java Installation: " + dir.getAbsolutePath());
Util.deleteDirectory(dir);
}
}