Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3818d4a

Browse files
Added support for adding default launch arguments
1 parent 23a1f50 commit 3818d4a

File tree

6 files changed

+49
-3
lines changed

6 files changed

+49
-3
lines changed

‎README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ By default it will generate next artifacts in `${outputDirectory} ` folder:
145145
### Plugin configuration properties
146146

147147
| Property | Mandatory | Default value | Description |
148-
|--------------------------|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
148+
|----------------------------|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
149149
| `additionalModulePaths` | :x: | `[]` | Additional module paths for `jdeps`. |
150150
| `additionalModules` | :x: | `[]` | Additional modules to the ones identified by `jdeps` or the specified with `modules` property. |
151151
| `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:
186186
| `useResourcesAsWorkingDir` | :x: | `true` | Uses app resources folder as default working directory (always `true` on MacOS). |
187187
| `version` | :x: | `${project.version}` | App version. |
188188
| `vmArgs` | :x: | `[]` | VM arguments. |
189+
| `appArgs` | :x: | `[]` | Additional arguments when launching the application. |
189190

190191
> [!IMPORTANT]
191192
> Some default values depends on the used building tool.

‎src/main/java/io/github/fvarrui/javapackager/gradle/PackageTask.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,18 @@ public void setVmArgs(List<String> vmArgs) {
445445
this.vmArgs = vmArgs;
446446
}
447447

448+
@Input
449+
@Optional
450+
private List<String> appArgs;
451+
452+
public List<String> getAppArgs() {
453+
return appArgs;
454+
}
455+
456+
public void setAppArgs(List<String> appArgs) {
457+
this.appArgs = appArgs;
458+
}
459+
448460
@Input
449461
@Optional
450462
private WindowsConfig winConfig;
@@ -656,6 +668,7 @@ protected Packager createPackager() throws Exception {
656668
.url(defaultIfNull(url, extension.getUrl()))
657669
.version(defaultIfNull(version, extension.getVersion(), getProject().getVersion().toString()))
658670
.vmArgs(defaultIfNull(vmArgs, extension.getVmArgs()))
671+
.appArgs(defaultIfNull(appArgs, extension.getAppArgs()))
659672
.winConfig(defaultIfNull(winConfig, extension.getWinConfig()));
660673

661674
}

‎src/main/java/io/github/fvarrui/javapackager/maven/PackageMojo.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,12 @@ public class PackageMojo extends AbstractMojo {
199199
*/
200200
@Parameter(property = "vmArgs", required = false)
201201
private List<String> vmArgs;
202+
203+
/**
204+
* Additional arguments to provide to the application
205+
*/
206+
@Parameter(property = "appArgs", readonly = false)
207+
private List<String> appArgs;
202208

203209
/**
204210
* 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 {
387393
.url(url)
388394
.version(version)
389395
.vmArgs(vmArgs)
396+
.appArgs(appArgs)
390397
.winConfig(winConfig);
391398

392399
// generate app, installers and bundles

‎src/main/java/io/github/fvarrui/javapackager/packagers/PackagerSettings.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class PackagerSettings {
4848
protected Platform platform;
4949
protected String envPath;
5050
protected List<String> vmArgs;
51+
protected List<String> appArgs;
5152
protected File runnableJar;
5253
protected Boolean copyDependencies;
5354
protected String jreDirectoryName;
@@ -279,6 +280,14 @@ public List<String> getVmArgs() {
279280
return vmArgs;
280281
}
281282

283+
/**
284+
* Get application args
285+
* @return Application args
286+
*/
287+
public List<String> getAppArgs() {
288+
return appArgs;
289+
}
290+
282291
/**
283292
* Get runnable JAR
284293
* @return Runnable JAR
@@ -685,6 +694,11 @@ public PackagerSettings vmArgs(List<String> vmArgs) {
685694
return this;
686695
}
687696

697+
public PackagerSettings appArgs(List<String> appArgs) {
698+
this.appArgs = new ArrayList<>(appArgs);
699+
return this;
700+
}
701+
688702
/**
689703
* Set runnable JAR
690704
* @param runnableJar Runnable JAR

‎src/main/resources/linux/startup.sh.vtl‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#set ($vmArgs = $StringUtils.join($info.vmArgs, " "))
2+
#set ($appArgs = $StringUtils.join($info.appArgs, " "))
23
#!/usr/bin/env bash
34
# GNU/Linux startup script generated by JavaPackager plugin
45

@@ -72,6 +73,8 @@ JVMClassPath="$BINARY"
7273
JVMClassPath+=":${classpath}"
7374
#end
7475

76+
AppArguments="${appArgs}"
77+
7578
#if ($info.useResourcesAsWorkingDir)
7679
cd "$SCRIPTPATH"
7780
#end
@@ -82,8 +85,8 @@ Bootstrap="$SCRIPTPATH/scripts/${info.bootstrapFile.name}" && [ -x "$Bootstrap"
8285
#end
8386

8487
#if ($info.administratorRequired)
85-
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY GDKBACKEND=x11 "${JAVA}" ${JVMDefaultOptions} -jar "${JVMClassPath}" $@
88+
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY GDKBACKEND=x11 "${JAVA}" ${JVMDefaultOptions} -jar "${JVMClassPath}" ${AppArguments} $@
8689
#else
87-
"${JAVA}" ${JVMDefaultOptions} -jar "${JVMClassPath}" $@
90+
"${JAVA}" ${JVMDefaultOptions} -jar "${JVMClassPath}" ${AppArguments} $@
8891
#end
8992
exit 0

‎src/main/resources/mac/Info.plist.vtl‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@
124124
<false/>
125125
#end
126126
</dict>
127+
#if ($info.appArgs)
128+
<key>Arguments</key>
129+
<array>
130+
#foreach ($appArg in $info.appArgs)
131+
<string>$appArg</string>
132+
#end
133+
</array>
134+
#end
127135
<key>LSEnvironment</key>
128136
<dict>
129137
#if ($info.bundleJre)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /