[GRADLE-1456] Convention property to set JAVA_OPTS/APPL_OPTS in application plugin Created: 25/Mar/11  Updated: 20/May/13  Resolved: 03/May/13

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-1
Fix Version/s: 1.7-rc-1

Type: Improvement
Reporter: Benjamin Muschko Assignee: René Gröschke (Inactive)
Resolution: Fixed Votes: 12


 Description   

I would like to be able to set the values of JAVA_OPTS and APPL_OPTS in the generated shell scripts as convention properties. Right now this is not possible. It would be great if they could be added.



 Comments   
Comment by René Gröschke (Inactive) [ 30/Mar/11 ]

The task of type CreateStartScripts used for generating the startscripts can be modified to implement the same api for adding default jvm arguments as JavaExec already does. ("jvmArgs << "your property") I'll have a look at this.

Comment by René Gröschke (Inactive) [ 09/Jun/11 ]

I would like to work on this issue. Shouldn't a convention property here (e.g. applicationJvmArgs ? ) be linked to the run task AND to the startScripts task?

Comment by Andrew Oberstar [ 08/Jan/12 ]

The scripts that get created have a DEFAULT_JVM_OPTS variable. Might just want to expose a way to set that, as opposed to setting JAVA_OPTS or APPL_OPTS, as those seem to be geared towards using the user's values.

Comment by Ryan J [ 21/Jan/12 ]

I'd like to see the default JVM options pulled straight from the run.jvmargs property, but it's worth pointing out that paths would need to be fixed up somehow then. Consider:

    -Djava.library.path=${buildDir}/javafx-native-libs

..in the run task vs

    -Djava.library.path=%APP_HOME%/javafx-native-libs

.. in the start script.

Maybe the application plugin should give the user a (ex) 'workingDir' property that all paths can be based off of. Then again, replacing "${buildDir}/" with "../" would be good enough (at least for me).

Comment by Andrew Oberstar [ 21/Jan/12 ]

Instead using the value from run.jvmargs, I think there would probably need to be an extension value (say application.defaultJvmArgs) that would be set as a convention value on both run.jvmArgs and a new startScripts.defaultJvmArgs property.

However, I agree that the sticking point is really when you have to reference paths within the app. It would have to be some type of token that would be replaced depending on the OS.

For example:
APP_HOME on Windows would be: %~do0..
APP_HOME on Unix would be: `dirname ${0%/*}`

But I'm not seeing an easy way to use a token, especially if it needs to resolve to something for the run task as well.

Comment by Robert Kasanicky [ 13/Jul/12 ]

Perhaps supporting static parameters can be the first step? E.g. I simply need to set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8

Comment by Kirk Stork [ 12/Dec/12 ]

+1

Anyplace where the shell script has a blank where the end user might customize the script should also be a place where the gradle build can insert defaults other than blanks.

Comment by René Gröschke (Inactive) [ 02/May/13 ]

I've just merged a related pull request (see https://github.com/gradle/gradle/pull/116 for details). You are now able to set default jvm args via convention property or directly in the CreateStartScripts task. feedback appreciated!

Generated at Wed Jun 30 11:55:58 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.