mirror of
https://hub.spigotmc.org/stash/scm/spigot/buildtools.git
synced 2025-04-13 09:31:28 +00:00
Fixed several launch bugs.
- Program exiting before GUI launch. - Moved java modal warnings to compile phase rather than version selection phase. - Removed some unused commented code and methods.
This commit is contained in:
parent
135c113102
commit
3591c955f2
6 changed files with 53 additions and 53 deletions
|
@ -33,25 +33,25 @@ public class Bootstrap
|
|||
}
|
||||
}
|
||||
|
||||
JavaVersion javaVersion = JavaVersion.getCurrentVersion();
|
||||
|
||||
if ( javaVersion.isUnknown() )
|
||||
{
|
||||
System.err.println( "*** WARNING *** Unsupported Java detected (" + System.getProperty( "java.class.version" ) + "). BuildTools has only been tested up to Java 21. Use of development Java versions is not supported." );
|
||||
System.err.println( "*** WARNING *** You may use java -version to double check your Java version." );
|
||||
}
|
||||
|
||||
long memoryMb = Runtime.getRuntime().maxMemory() >> 20;
|
||||
if ( memoryMb < 448 ) // Older JVMs (including Java 8) report less than Xmx here. Allow some slack for people actually using -Xmx512M
|
||||
{
|
||||
System.err.println( "BuildTools requires at least 512M of memory to run (1024M recommended), but has only detected " + memoryMb + "M." );
|
||||
System.err.println( "This can often occur if you are running a 32-bit system, or one with low RAM." );
|
||||
System.err.println( "Please re-run BuildTools with manually specified memory, e.g: java -Xmx1024M -jar BuildTools.jar " + Joiner.on( ' ' ).join( args ) );
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
if ( !guiEnabled )
|
||||
{
|
||||
JavaVersion javaVersion = JavaVersion.getCurrentVersion();
|
||||
|
||||
if ( javaVersion.isUnknown() )
|
||||
{
|
||||
System.err.println( "*** WARNING *** Unsupported Java detected (" + System.getProperty( "java.class.version" ) + "). BuildTools has only been tested up to Java 21. Use of development Java versions is not supported." );
|
||||
System.err.println( "*** WARNING *** You may use java -version to double check your Java version." );
|
||||
}
|
||||
|
||||
long memoryMb = Runtime.getRuntime().maxMemory() >> 20;
|
||||
if ( memoryMb < 448 ) // Older JVMs (including Java 8) report less than Xmx here. Allow some slack for people actually using -Xmx512M
|
||||
{
|
||||
System.err.println( "BuildTools requires at least 512M of memory to run (1024M recommended), but has only detected " + memoryMb + "M." );
|
||||
System.err.println( "This can often occur if you are running a 32-bit system, or one with low RAM." );
|
||||
System.err.println( "Please re-run BuildTools with manually specified memory, e.g: java -Xmx1024M -jar BuildTools.jar " + Joiner.on( ' ' ).join( args ) );
|
||||
System.exit( 1 );
|
||||
}
|
||||
|
||||
Builder.logOutput( System.out, System.err );
|
||||
Builder.main( args );
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ public final class BuildData {
|
|||
*
|
||||
* @param buildSettings the buildSettings used to get the current selected spigot version
|
||||
*/
|
||||
public void updateJavaExecutable(final BuildSettings buildSettings) {
|
||||
public CompletableFuture<Boolean> updateJavaExecutable(final BuildSettings buildSettings, boolean showModal) {
|
||||
String checkVersion = buildSettings.getVersion();
|
||||
if (checkVersion.equals("experimental")) {
|
||||
String mostRecent = versions.get(2);
|
||||
|
@ -106,12 +106,7 @@ public final class BuildData {
|
|||
checkVersion = mostRecent;
|
||||
}
|
||||
|
||||
builds.get(checkVersion).whenComplete((BuildInfo info, Throwable throwable) -> {
|
||||
if (throwable != null) {
|
||||
MessageModal.displayError(Utils.getReadableStacktrace(throwable));
|
||||
return;
|
||||
}
|
||||
|
||||
return builds.get(checkVersion).thenApply((BuildInfo info) -> {
|
||||
if (info.getJavaVersions() == null) {
|
||||
info.setJavaVersions(new int[]{
|
||||
JavaVersion.JAVA_7.getVersion(),
|
||||
|
@ -125,7 +120,7 @@ public final class BuildData {
|
|||
final JavaInstallation primary = javaInstallationManager.getPrimaryInstallation();
|
||||
if (primary.getVersion().getClassFileMajorVersion() >= min.getVersion() && primary.getVersion().getClassFileMajorVersion() <= max.getVersion()) {
|
||||
javaInstallationManager.setSelectedInstallation(primary);
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
JavaInstallation newInstallation = null;
|
||||
|
@ -143,27 +138,34 @@ public final class BuildData {
|
|||
}
|
||||
|
||||
if (newInstallation == null) {
|
||||
String style = Utils.getFileContentsFromResource("web/reset.css");
|
||||
String message = Utils.getFileContentsFromResource("web/insufficient_java.html");
|
||||
message = message.replace("%STYLESHEET%", "<style>" + style + "</style>");
|
||||
message = message.replace("%JAVA_VERSION_MIN%", min.getName());
|
||||
message = message.replace("%JAVA_VERSION_MAX%", max.getName());
|
||||
message = message.replace("%VERSION%", buildSettings.getVersion());
|
||||
message = message.replace("%OPENJDK_LINK%", Constants.DOWNLOAD_OPENJDK);
|
||||
message = message.replace("%AZUL_LINK%", Constants.DOWNLOAD_AZUL);
|
||||
message = message.replace("%ORACLE_LINK%", Constants.DOWNLOAD_ORACLE);
|
||||
if (showModal) {
|
||||
String style = Utils.getFileContentsFromResource("web/reset.css");
|
||||
String message = Utils.getFileContentsFromResource("web/insufficient_java.html");
|
||||
message = message.replace("%STYLESHEET%", "<style>" + style + "</style>");
|
||||
message = message.replace("%JAVA_VERSION_MIN%", min.getName());
|
||||
message = message.replace("%JAVA_VERSION_MAX%", max.getName());
|
||||
message = message.replace("%VERSION%", buildSettings.getVersion());
|
||||
message = message.replace("%OPENJDK_LINK%", Constants.DOWNLOAD_OPENJDK);
|
||||
message = message.replace("%AZUL_LINK%", Constants.DOWNLOAD_AZUL);
|
||||
message = message.replace("%ORACLE_LINK%", Constants.DOWNLOAD_ORACLE);
|
||||
|
||||
MessageModal.displayError(message);
|
||||
return;
|
||||
MessageModal.displayError(message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
javaInstallationManager.setSelectedInstallation(newInstallation);
|
||||
return true;
|
||||
}).whenComplete((Boolean completed, Throwable throwable) -> {
|
||||
if (throwable != null) {
|
||||
MessageModal.displayError(Utils.getReadableStacktrace(throwable));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a copy of the versions list.
|
||||
* */
|
||||
* @return a copy of the versions list.
|
||||
*/
|
||||
public List<String> getVersions() {
|
||||
return new ArrayList<>(versions);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.spigotmc.gui.panels.general;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import org.spigotmc.gui.BuildToolsProcess;
|
||||
import org.spigotmc.gui.attributes.Lockable;
|
||||
import org.spigotmc.gui.data.BuildSettings;
|
||||
|
@ -149,6 +150,15 @@ public class GeneralPanel extends JPanel implements Lockable {
|
|||
}
|
||||
|
||||
private void buildButtonActionPerformed(ActionEvent event) {
|
||||
try {
|
||||
if (!buildData.updateJavaExecutable(buildSettings, true).get()) {
|
||||
return;
|
||||
}
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
MessageModal.displayError(Utils.getReadableStacktrace(e));
|
||||
return;
|
||||
}
|
||||
|
||||
cancelButton.setEnabled(true);
|
||||
consolePane.updateConsoleAreaText(new ArrayList<>());
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ public class SettingsPanel extends JPanel implements Lockable, Themeable {
|
|||
|
||||
buildSettings.setVersion(selected);
|
||||
if (!buildSettings.isOverrideJavaExecutable()) {
|
||||
buildData.updateJavaExecutable(buildSettings);
|
||||
buildData.updateJavaExecutable(buildSettings, false);
|
||||
}
|
||||
|
||||
consolePane.updateConsoleAreaText(buildData.generatePreCompilationText(buildSettings));
|
||||
|
|
|
@ -441,7 +441,7 @@ public class OptionsPanel extends JPanel {
|
|||
this.detectJavaButton.setEnabled(false);
|
||||
this.javaSelectionButton.setEnabled(false);
|
||||
buildSettings.setOverrideJavaExecutable(false);
|
||||
buildData.updateJavaExecutable(buildSettings);
|
||||
buildData.updateJavaExecutable(buildSettings, false);
|
||||
}
|
||||
|
||||
// Text Fields
|
||||
|
|
|
@ -91,19 +91,7 @@ public class Utils {
|
|||
}
|
||||
|
||||
public static boolean isRanFromCommandLine() {
|
||||
// If a console is available, we're definitely running from command line.
|
||||
if (System.console() != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Naive check for running from command line on Windows.
|
||||
// If ran from command line or inside most IDEs, the SESSIONNAME environment variable will be set to "Console".
|
||||
// It will be unset when double-clicking the .jar or when using other OSes
|
||||
if ("Console".equals(System.getenv("SESSIONNAME"))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return System.console() != null;
|
||||
}
|
||||
|
||||
public static boolean isValidPR(String input, Repository repository) {
|
||||
|
|
Loading…
Add table
Reference in a new issue