Ankush
Ankush

Reputation: 519

How can I pass VM arguments to gradle from command line?

How can I pass VM arguments to gradle from command line. The Gradle Tool option in Idea is working fine ( screehshot attached). I am trying to pass --add-opens to gradle and am aware of -P but it is not working.

The GRADLE VM options from the Idea

Upvotes: 16

Views: 37581

Answers (3)

zeeke
zeeke

Reputation: 64

You can use the GRADLE_OPTS environment variable. Here is the documentation

Upvotes: 4

ultraon
ultraon

Reputation: 2400

Try this:

./gradlew -Dorg.gradle.jvmargs=-Xmx16g wrapper

NOTE

  • Pay attention to -D, this marks the property to be passed to Gradle and JVM.
  • Using -P a property is passed as Gradle project property.

Upvotes: 19

Dave Kraczo
Dave Kraczo

Reputation: 908

Hi for Intellij IDEA run you can add property to JM Options at Run Configuration. First make sure you have enabled add VM options at Modify Options enter image description here

After that add --add-opens java.base/java.util=ALL-UNNAMED to vm option

enter image description here

For deployment add options to gradle run as @ultraon described or for Docker add to run_script.sh as JAVA_OPTS

JAVA_OPTS="-XX:+UseG1GC
-Xms512m
-Xmx2048m
--add-opens java.base/java.util=ALL-UNNAMED -Dspring.profiles.active=$PROFILE,discovery"

Upvotes: 0

Related Questions