-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade gradle, loads of JAR loading magic and command line
- Loading branch information
Showing
6 changed files
with
139 additions
and
11 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/main/java/link/infra/packwiz/installer/bootstrap/LoadJAR.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package link.infra.packwiz.installer.bootstrap; | ||
|
||
import java.io.File; | ||
import java.lang.reflect.Method; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import java.net.URLClassLoader; | ||
|
||
import org.apache.commons.cli.Options; | ||
|
||
public class LoadJAR { | ||
|
||
private static Class<?> mainClass = null; | ||
|
||
private static void loadClass(String path) throws MalformedURLException, ClassNotFoundException { | ||
if (mainClass != null) { | ||
return; | ||
} | ||
|
||
if (path == null) { | ||
path = "./packwiz-installer.jar"; | ||
} | ||
|
||
URLClassLoader child = new URLClassLoader(new URL[] { new File(path).toURI().toURL() }, | ||
LoadJAR.class.getClassLoader()); | ||
mainClass = Class.forName("link.infra.packwiz.installer.Main", true, child); | ||
} | ||
|
||
public static boolean addOptions(Options options, String path) { | ||
try { | ||
loadClass(path); | ||
|
||
Method method = mainClass.getDeclaredMethod("addNonBootstrapOptions", Options.class); | ||
method.invoke(null, options); | ||
} catch (Exception e) { | ||
// Woah that was a lot of errors! | ||
// Just ignore them, it doesn't matter if there aren't any more options added anyway - it's just a help command. | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
public static void start(String[] args, String path) throws ClassNotFoundException, Exception { | ||
loadClass(path); | ||
|
||
// Must be casted to Object (not array) because varargs | ||
mainClass.getConstructor(String[].class).newInstance((Object)args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters