edvin / fxlauncher

Auto updating launcher for JavaFX Applications
Apache License 2.0
713 stars 110 forks source link

Incorrect USERLIB cacheDir for spingboot application #131

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hi, i have notice that there is a bug when you retrieve the cacheDir while starting SpringBoot Application. If i set the cacheDir like --cache-dir=USERLIB/MyApp then.

i think that instead of

superLauncher.getManifest().cacheDir;

is better to use

this.superLauncher.getManifest().resolveCacheDir(this.getParameters().getNamed())

in the method below, to correctly resolve the USERLIB dir.

private void startApplication() throws Exception {
    if (app != null) {
        ParametersImpl.registerParameters(app, new LauncherParams(getParameters(), superLauncher.getManifest()));
        PlatformImpl.setApplicationName(app.getClass());
        superLauncher.setPhase("Application Init");
        app.start(primaryStage);
    } else {
        // Start any executable jar (i.E. Spring Boot);
        List<LibraryFile> files = superLauncher.getManifest().files;
        String cacheDir = superLauncher.getManifest().cacheDir;
        String command = String.format("java -jar %s/%s", cacheDir, files.get(0).file);
        log.info(String.format("Execute command '%s'", command));
        Runtime.getRuntime().exec(command);
    }
 }
edvin commented 6 years ago

Thank you, I've committed a fix :)