diff --git a/README.md b/README.md index 757fd9cf..0081560e 100644 --- a/README.md +++ b/README.md @@ -145,7 +145,7 @@ By default it will generate next artifacts in `${outputDirectory} ` folder: ### Plugin configuration properties | Property | Mandatory | Default value | Description | -| -------------------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +|----------------------------|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `additionalModulePaths` | :x: | `[]` | Additional module paths for `jdeps`. | | `additionalModules` | :x: | `[]` | Additional modules to the ones identified by `jdeps` or the specified with `modules` property. | | `additionalResources` | :x: | `[]` | Additional files and folders to include in the bundled app. | @@ -186,6 +186,7 @@ By default it will generate next artifacts in `${outputDirectory} ` folder: | `useResourcesAsWorkingDir` | :x: | `true` | Uses app resources folder as default working directory (always `true` on MacOS). | | `version` | :x: | `${project.version}` | App version. | | `vmArgs` | :x: | `[]` | VM arguments. | +| `appArgs` | :x: | `[]` | Additional arguments when launching the application. | > [!IMPORTANT] > Some default values depends on the used building tool. diff --git a/src/main/java/io/github/fvarrui/javapackager/gradle/PackageTask.java b/src/main/java/io/github/fvarrui/javapackager/gradle/PackageTask.java index ce6a321a..4f4120f8 100644 --- a/src/main/java/io/github/fvarrui/javapackager/gradle/PackageTask.java +++ b/src/main/java/io/github/fvarrui/javapackager/gradle/PackageTask.java @@ -445,6 +445,18 @@ public void setVmArgs(List vmArgs) { this.vmArgs = vmArgs; } + @Input + @Optional + private List appArgs; + + public List getAppArgs() { + return appArgs; + } + + public void setAppArgs(List appArgs) { + this.appArgs = appArgs; + } + @Input @Optional private WindowsConfig winConfig; @@ -656,6 +668,7 @@ protected Packager createPackager() throws Exception { .url(defaultIfNull(url, extension.getUrl())) .version(defaultIfNull(version, extension.getVersion(), getProject().getVersion().toString())) .vmArgs(defaultIfNull(vmArgs, extension.getVmArgs())) + .appArgs(defaultIfNull(appArgs, extension.getAppArgs())) .winConfig(defaultIfNull(winConfig, extension.getWinConfig())); } diff --git a/src/main/java/io/github/fvarrui/javapackager/maven/PackageMojo.java b/src/main/java/io/github/fvarrui/javapackager/maven/PackageMojo.java index 78d54203..2e8ca21a 100644 --- a/src/main/java/io/github/fvarrui/javapackager/maven/PackageMojo.java +++ b/src/main/java/io/github/fvarrui/javapackager/maven/PackageMojo.java @@ -199,6 +199,12 @@ public class PackageMojo extends AbstractMojo { */ @Parameter(property = "vmArgs", required = false) private List vmArgs; + + /** + * Additional arguments to provide to the application + */ + @Parameter(property = "appArgs", readonly = false) + private List appArgs; /** * Provide your own runnable .jar (for example, a shaded .jar) instead of letting this plugin create one via @@ -387,6 +393,7 @@ public void execute() throws MojoExecutionException { .url(url) .version(version) .vmArgs(vmArgs) + .appArgs(appArgs) .winConfig(winConfig); // generate app, installers and bundles diff --git a/src/main/java/io/github/fvarrui/javapackager/packagers/PackagerSettings.java b/src/main/java/io/github/fvarrui/javapackager/packagers/PackagerSettings.java index 4d560031..88d7ff81 100644 --- a/src/main/java/io/github/fvarrui/javapackager/packagers/PackagerSettings.java +++ b/src/main/java/io/github/fvarrui/javapackager/packagers/PackagerSettings.java @@ -48,6 +48,7 @@ public class PackagerSettings { protected Platform platform; protected String envPath; protected List vmArgs; + protected List appArgs; protected File runnableJar; protected Boolean copyDependencies; protected String jreDirectoryName; @@ -279,6 +280,14 @@ public List getVmArgs() { return vmArgs; } + /** + * Get application args + * @return Application args + */ + public List getAppArgs() { + return appArgs; + } + /** * Get runnable JAR * @return Runnable JAR @@ -685,6 +694,11 @@ public PackagerSettings vmArgs(List vmArgs) { return this; } + public PackagerSettings appArgs(List appArgs) { + this.appArgs = new ArrayList<>(appArgs); + return this; + } + /** * Set runnable JAR * @param runnableJar Runnable JAR diff --git a/src/main/resources/linux/startup.sh.vtl b/src/main/resources/linux/startup.sh.vtl index f6cb133f..14ad084a 100644 --- a/src/main/resources/linux/startup.sh.vtl +++ b/src/main/resources/linux/startup.sh.vtl @@ -1,4 +1,5 @@ #set ($vmArgs = $StringUtils.join($info.vmArgs, " ")) +#set ($appArgs = $StringUtils.join($info.appArgs, " ")) #!/usr/bin/env bash # GNU/Linux startup script generated by JavaPackager plugin @@ -72,6 +73,8 @@ JVMClassPath="$BINARY" JVMClassPath+=":${classpath}" #end +AppArguments="${appArgs}" + #if ($info.useResourcesAsWorkingDir) cd "$SCRIPTPATH" #end @@ -82,8 +85,8 @@ Bootstrap="$SCRIPTPATH/scripts/${info.bootstrapFile.name}" && [ -x "$Bootstrap" #end #if ($info.administratorRequired) -pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY GDKBACKEND=x11 "${JAVA}" ${JVMDefaultOptions} -jar "${JVMClassPath}" $@ +pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY GDKBACKEND=x11 "${JAVA}" ${JVMDefaultOptions} -jar "${JVMClassPath}" ${AppArguments} $@ #else -"${JAVA}" ${JVMDefaultOptions} -jar "${JVMClassPath}" $@ +"${JAVA}" ${JVMDefaultOptions} -jar "${JVMClassPath}" ${AppArguments} $@ #end exit 0 diff --git a/src/main/resources/mac/Info.plist.vtl b/src/main/resources/mac/Info.plist.vtl index 31ca5905..b98e668c 100644 --- a/src/main/resources/mac/Info.plist.vtl +++ b/src/main/resources/mac/Info.plist.vtl @@ -124,6 +124,14 @@ #end +#if ($info.appArgs) + Arguments + +#foreach ($appArg in $info.appArgs) + $appArg +#end + +#end LSEnvironment #if ($info.bundleJre)