Can't define platform specific DEFAULT_JVM_OPTS with application plugin

The ‘application’ plugin lets you define ‘defaultJvmArgs’ that are applied to all platforms. Unfortunately defining OSX specific settings (such as -Xdock:name and -Xdock:icon) causes trouble on Linux, even though IMHO these unrecognized options should be completely ignored by the JVM.

Here’s a sample error when these options are enabled on Linux

Unrecognized option: -Xdock:name=GuideCamTool

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

Is there a way to define platform specific JVM args?

Hey Andres, thanks for reporting this. I’ll have a look on this soon.

cheers, René

Hey, at the moment these attributes are hard-coded in the generated script, so you would need to apply your custom icons accordingly (see: https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt#L110-110)

We could improve set by changing the https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/groovy/org/gradle/api/internal/plugins/StartScriptGenerator.groovy to handle platform specific properties different. I can see this could be a good hackergarten session :wink:

Indeed.

Those default icons only make sense when generating Gradle specific scripts, but not those created by the ‘application’ plugin. I’d love to see a platform specific jvmArgs property, something along the lines of

platformJvmArgs = [

darwin: ["-Xdock:icon=$APP_HOME/resources/app.icns"]

]

We have 2 upcoming Hackergarten sessions (Basel & Luzern) in January; perhaps we can tackle this issue. I think a signed CLA is required for making contributions to the gradle core, isn’t it?

Cheers, Andres

That’s correct, it can be signed electronically at http://www.gradleware.com/contributor-agreement.

Done. Also opened a discussion topic at gradle-dev to flesh out ideas and hopefully make a contribution soon :slight_smile: