mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-04-20 05:26:30 +02:00
Store version, move main to seperate class
This commit is contained in:
parent
599d86e7b7
commit
b3cac7b544
@ -2,6 +2,7 @@ plugins {
|
|||||||
id 'java'
|
id 'java'
|
||||||
id 'application'
|
id 'application'
|
||||||
id 'com.github.johnrengelman.shadow' version '5.0.0'
|
id 'com.github.johnrengelman.shadow' version '5.0.0'
|
||||||
|
id 'com.palantir.git-version' version '0.11.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -13,12 +14,14 @@ repositories {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
|
|
||||||
mainClassName = 'link.infra.packwiz.installer.Main'
|
mainClassName = 'link.infra.packwiz.installer.RequiresBootstrap'
|
||||||
|
version gitVersion()
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
manifest {
|
manifest {
|
||||||
attributes(
|
attributes(
|
||||||
'Main-Class': 'link.infra.packwiz.installer.Main'
|
'Main-Class': 'link.infra.packwiz.installer.RequiresBootstrap',
|
||||||
|
'Implementation-Version': project.version
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,28 +10,7 @@ import org.apache.commons.cli.ParseException;
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
// Actual main() is in RequiresBootstrap!
|
||||||
Options options = new Options();
|
|
||||||
options.addOption("g", "no-gui", false, "Don't display a GUI to show update progress");
|
|
||||||
|
|
||||||
CommandLineParser parser = new DefaultParser();
|
|
||||||
CommandLine cmd = null;
|
|
||||||
try {
|
|
||||||
// Allow any arguments, we're going to exit(1) anyway
|
|
||||||
cmd = parser.parse(options, args, false);
|
|
||||||
} catch (ParseException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
JOptionPane.showMessageDialog(null, e.getMessage(), "packwiz-installer", JOptionPane.ERROR_MESSAGE);
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
if (cmd.hasOption("no-gui")) {
|
|
||||||
System.out.println("This program must be run through packwiz-installer-bootstrap. Use --bootstrap-no-update to disable updating.");
|
|
||||||
System.exit(1);
|
|
||||||
} else {
|
|
||||||
JOptionPane.showMessageDialog(null, "This program must be run through packwiz-installer-bootstrap. Use --bootstrap-no-update to disable updating.", "packwiz-installer", JOptionPane.ERROR_MESSAGE);
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Main(String[] args) {
|
public Main(String[] args) {
|
||||||
Options options = new Options();
|
Options options = new Options();
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package link.infra.packwiz.installer;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.UIManager;
|
||||||
|
|
||||||
|
public class RequiresBootstrap {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// Very small CLI implementation, because Commons CLI complains on unexpected
|
||||||
|
// options
|
||||||
|
// Also so that Commons CLI can be excluded from the shaded JAR, as it is
|
||||||
|
// included in the bootstrap
|
||||||
|
if (Arrays.stream(args).map(str -> {
|
||||||
|
if (str == null) return "";
|
||||||
|
if (str.startsWith("--")) {
|
||||||
|
return str.substring(2, str.length());
|
||||||
|
}
|
||||||
|
if (str.startsWith("-")) {
|
||||||
|
return str.substring(1, str.length());
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}).anyMatch(str -> str.equals("g") || str.equals("no-gui"))) {
|
||||||
|
System.out.println(
|
||||||
|
"This program must be run through packwiz-installer-bootstrap. Use --bootstrap-no-update to disable updating.");
|
||||||
|
System.exit(1);
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Ignore the exceptions, just continue using the ugly L&F
|
||||||
|
}
|
||||||
|
JOptionPane.showMessageDialog(null,
|
||||||
|
"This program must be run through packwiz-installer-bootstrap. Use --bootstrap-no-update to disable updating.",
|
||||||
|
"packwiz-installer", JOptionPane.ERROR_MESSAGE);
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user