Reputation:
I tried the org.gradle.jvmargs in gradle.properties, but it doesn't work. Specifically, I'm trying to change the GC of the JVM of my program, with Gradle. I don't care about the JVM Gradle runs on, but the one my application does.
Upvotes: 5
Views: 11744
Reputation: 719661
The Gradle documentation for the Application Plugin says this:
If your application requires a specific set of JVM settings or system properties, you can configure the
applicationDefaultJvmArgs
property. These JVM arguments are applied to the run task and also considered in the generated start scripts of your distribution.
You should put the GC options into that property.
Note that this won't directly affect the behavior of an executable JAR if you execute it directly; i.e. without using the generated start scripts.
There are two other alternatives (solely!) for the case where you are running the application from Gradle.
The JavaExec
task type allows you to set the JVM options via various properties; see the JavaExec API documentation
The Exec
task type allows you to run an arbitrary command with arbitrary arguments. However if you use this to run a Java application, you will need to "wrangle" all of the command line options yourself.
Upvotes: 2