1.0.3
All checks were successful
FreshCoffee/pipeline/head This commit looks good

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 # Changelog
**1.0.3**
* Improve Java Binary Testing
**1.0.2** **1.0.2**
* Fix 32-Bit OpenJDk Installation * Fix 32-Bit OpenJDk Installation

View File

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

View File

@ -23,7 +23,7 @@ public class FreshCoffee implements PreLaunchEntrypoint {
System.exit(1); System.exit(1);
} }
ReLaunchUtil.reLaunch(); ReLaunchUtil.reLaunch(true);
// Download Available JDKs // Download Available JDKs
AdoptOpenJDK.JDK jdk = AdoptOpenJDK.get().get(PlatformUtil.getPlatform()); AdoptOpenJDK.JDK jdk = AdoptOpenJDK.get().get(PlatformUtil.getPlatform());
@ -49,7 +49,7 @@ public class FreshCoffee implements PreLaunchEntrypoint {
ExtractUtil.extract(url, dir); ExtractUtil.extract(url, dir);
ReLaunchUtil.reLaunch(); ReLaunchUtil.reLaunch(false);
} }
System.exit(1); 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) { private static boolean testJavaBinary(String javaBinary) {
Util.getLogger().debug("Testing Java Binary: " + javaBinary);
Process process; Process process;
try { try {
process = new ProcessBuilder(javaBinary, "-version").start(); process = new ProcessBuilder(javaBinary, "-version").start();
} catch (IOException e) { } catch (IOException e) {
javaBinaryTestFailed(e.toString());
return false; return false;
} }
try { try {
int status = process.waitFor(); int status = process.waitFor();
javaBinaryTestFailed("Exit Code: " + status);
return status == 0; return status == 0;
} catch (InterruptedException e) { } catch (InterruptedException e) {
javaBinaryTestFailed(e.toString());
process.destroy(); process.destroy();
return false; return false;
} }
} }
public static void reLaunch() { public static void reLaunch(boolean testJavaBinary) {
File[] files = HardcodedConfig.INSTALL_DIR.listFiles(); File[] files = HardcodedConfig.INSTALL_DIR.listFiles();
if (files != null) { if (files != null) {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
@ -142,7 +151,7 @@ public final class ReLaunchUtil {
if (newestVersion != null) { if (newestVersion != null) {
File javaDir = Util.getJavaDir(newestVersion); File javaDir = Util.getJavaDir(newestVersion);
File javaBinary = new File(new File(javaDir, "bin"), "java" + PlatformUtil.getExecutableExtension()); 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()); Util.getLogger().info("Using Java Executable: " + javaBinary.getAbsolutePath());
reLaunch(javaBinary.getAbsolutePath()); reLaunch(javaBinary.getAbsolutePath());
} else { } else {