Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 349
Ankush Avatar asked Jan 30 '17 07:01

Ankush


People also ask

How do you pass arguments in Gradle test?

When you run gradle test -Darg1=smth , you pass system parameter arg1 to the Gradle JVM, not the test JVM where tests are run. It is designed this way to protect tests from side effects. and run it the same way.

How do I set Gradle VM options?

Add VM options for the Gradle project You can specify VM options for your Gradle project using the gradle. properties file. Create or open your Gradle project. In the Project tool window, right-click the project and from the context menu, select New | File.

How do I run a Gradle task from the command line?

To run a Gradle command, open a command window on the project folder and enter the Gradle command. Gradle commands look like this: On Windows: gradlew <task1> <task2> … ​ e.g. gradlew clean allTests.


2 Answers

Try to use ./gradlew -Dorg.gradle.jvmargs=-Xmx16g wrapper, pay attention on -D, this marks the property to be passed to gradle and jvm. Using -P a property is passed as gradle project property.

like image 50
ultraon Avatar answered Sep 19 '22 21:09

ultraon


You can use the GRADLE_OPTS environment variable. Here the documentation

like image 38
zeeke Avatar answered Sep 20 '22 21:09

zeeke