Uploaded image for project: 'Gradle'
  1. Gradle
  2. GRADLE-1456

Convention property to set JAVA_OPTS/APPL_OPTS in application plugin

    Details

    • Type: Improvement
    • Status: Resolved
    • Resolution: Fixed
    • Affects Version/s: 1.0-milestone-1
    • Fix Version/s: 1.7-rc-1

      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.

        Activity

        Hide
        breskeby René Gröschke added a comment -

        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.

        Show
        breskeby René Gröschke added a comment - 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.
        Hide
        breskeby René Gröschke added a comment - - edited

        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?

        Show
        breskeby René Gröschke added a comment - - edited 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?
        Hide
        ajoberstar Andrew Oberstar added a comment -

        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.

        Show
        ajoberstar Andrew Oberstar added a comment - 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.
        Hide
        jptech Ryan J added a comment -

        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).

        Show
        jptech Ryan J added a comment - 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).
        Hide
        ajoberstar Andrew Oberstar added a comment -

        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.

        Show
        ajoberstar Andrew Oberstar added a comment - 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.
        Hide
        robokaso Robert Kasanicky added a comment -

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

        Show
        robokaso Robert Kasanicky added a comment - Perhaps supporting static parameters can be the first step? E.g. I simply need to set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8
        Hide
        kastork@nps.edu Kirk Stork added a comment -

        +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.

        Show
        kastork@nps.edu Kirk Stork added a comment - +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.
        Hide
        breskeby René Gröschke added a comment - - edited

        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!

        Show
        breskeby René Gröschke added a comment - - edited 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!

          People

          • Assignee:
            breskeby René Gröschke
            Reporter:
            bmuschko Benjamin Muschko
          • Votes:
            12 Vote for this issue
            Watchers:
            13 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development