libgdx / packr

Packages your JAR, assets and a JVM for distribution on Windows, Linux and Mac OS X
Apache License 2.0
2.56k stars 171 forks source link

Mulitiple vmArgs in json doesn't works #206

Closed cervenf closed 3 years ago

cervenf commented 3 years ago

I have packr-config.json like this (with multiple vmArgs) :

{
    "platform": "windows64",
    "jdk": "openjdk-11+28_windows-x64_bin.zip",
    "executable": "my-app",
    "classpath": [
        "my-app.jar"
    ],
    "mainclass": "org.springframework.boot.loader.JarLauncher",
    "vmArgs": [
        "-Dspring.profiles.active=local,local-user",
        "-Dfile.encoding=UTF-8"
    ],
    "minimizejre": "soft",
    "output": "my-app"
}

and when I execute: java -jar packr-all-4.0.0.jar packr-config.json

it will generate json with empty vmArgs:

{
  "jrePath": "jre",
  "classPath": [
    "my-app.jar"
  ],
  "mainClass": "org.springframework.boot.loader.JarLauncher",
  "useZgcIfSupportedOs": false,
  "vmArgs": [
  ]
}

Did I miss something in packr-config.json please? Thank you.

karlsabo commented 3 years ago

Hey @ferinoc,

It looks like the Java code might only accept vmargs all lowercase.

          if (json.get("vmargs") != null) {
                List<String> vmArgs = toStringArray(json.get("vmargs").asArray());
                this.vmArgs = new ArrayList<>();
                for (String vmArg : vmArgs) {
                     if (vmArg.startsWith("-")) {
                          this.vmArgs.add(vmArg.substring(1));
                     } else {
                          this.vmArgs.add(vmArg);
                     }
                }
          }

Hopefully that fixes the issue for you.

cervenf commented 3 years ago

@karlsabo Thank you very much for good spot. Now it works :)

karlsabo commented 3 years ago

Thanks for letting me know it worked.