1.0.3
FreshCoffee/pipeline/head This commit looks good Details

This commit is contained in:
TheBrokenRail 2020-08-23 16:46:02 -04:00
parent 2020b895b9
commit 7f828767a8
4 changed files with 17 additions and 5 deletions

View File

@ -1,5 +1,8 @@
# Changelog
**1.0.3**
* Improve Java Binary Testing
**1.0.2**
* Fix 32-Bit OpenJDk Installation

View File

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

View File

@ -23,7 +23,7 @@ public class FreshCoffee implements PreLaunchEntrypoint {
System.exit(1);
}
ReLaunchUtil.reLaunch();
ReLaunchUtil.reLaunch(true);
// Download Available JDKs
AdoptOpenJDK.JDK jdk = AdoptOpenJDK.get().get(PlatformUtil.getPlatform());
@ -49,7 +49,7 @@ public class FreshCoffee implements PreLaunchEntrypoint {
ExtractUtil.extract(url, dir);
ReLaunchUtil.reLaunch();
ReLaunchUtil.reLaunch(false);
}
System.exit(1);

View File

@ -110,24 +110,33 @@ public final class ReLaunchUtil {
}
}
private static void javaBinaryTestFailed(String reason) {
Util.getLogger().debug("Java Binary Test Failed: " + reason);
}
private static boolean testJavaBinary(String javaBinary) {
Util.getLogger().debug("Testing Java Binary: " + javaBinary);
Process process;
try {
process = new ProcessBuilder(javaBinary, "-version").start();
} catch (IOException e) {
javaBinaryTestFailed(e.toString());
return false;
}
try {
int status = process.waitFor();
javaBinaryTestFailed("Exit Code: " + status);
return status == 0;
} catch (InterruptedException e) {
javaBinaryTestFailed(e.toString());
process.destroy();
return false;
}
}
public static void reLaunch() {
public static void reLaunch(boolean testJavaBinary) {
File[] files = HardcodedConfig.INSTALL_DIR.listFiles();
if (files != null) {
List<String> list = new ArrayList<>();
@ -142,7 +151,7 @@ public final class ReLaunchUtil {
if (newestVersion != null) {
File javaDir = Util.getJavaDir(newestVersion);
File javaBinary = new File(new File(javaDir, "bin"), "java" + PlatformUtil.getExecutableExtension());
if (javaBinary.exists() && javaBinary.canExecute() && testJavaBinary(javaBinary.getAbsolutePath())) {
if (!testJavaBinary || testJavaBinary(javaBinary.getAbsolutePath())) {
Util.getLogger().info("Using Java Executable: " + javaBinary.getAbsolutePath());
reLaunch(javaBinary.getAbsolutePath());
} else {