Gradle JavaExec Challenge how to use allJvmArgs property
As per Java Exec allJvmArgs javadoc property, allJvmArgs
List<String> allJvmArgs
The full set of arguments to use to launch the JVM for the process. This includes arguments to define system properties, the minimum/maximum heap size, and the bootstrap classpath.
I am trying to use this property unsuccessfully. Below are my estimates.
Sample Java code. // src / core / java / com / examples
package com.examples;
public class AllJvmArgumentsInJavaExecBug {
public static void main(String[] args) {
System.out.println("Hello From Java");
}
}
// File: build.gradle
apply plugin: 'java'
task(runJavaExecNormal, dependsOn: 'classes', type: JavaExec) {
main = 'com.examples.AllJvmArgumentsInJavaExecBug'
classpath = sourceSets.main.runtimeClasspath
}
task(runJavaExecArgumentSetExample1, dependsOn: 'classes', type: JavaExec) {
main = 'com.examples.AllJvmArgumentsInJavaExecBug'
classpath = sourceSets.main.runtimeClasspath
allJvmArgs = [ '-Xms10240m', '-Xmx20280m']
}
task(runJavaExecArgumentSetExample2, dependsOn: 'classes', type: JavaExec) {
main = 'com.examples.AllJvmArgumentsInJavaExecBug'
classpath = sourceSets.main.runtimeClasspath
List<String> argumentList = new ArrayList<String>();
argumentList.add('-Xms10240m')
argumentList.add('-Xmx20280m')
allJvmArgs = argumentList
}
I am getting the following error.
P:\github\gradleJavaExecAllJvmArgs>gradle
FAILURE: Build failed with an exception.
* Where:
Build file 'P:\github\gradleJavaExecAllJvmArgs\build.gradle' line: 14
* What went wrong:
A problem occurred evaluating root project 'gradleJavaExecAllJvmArgs'.
> java.lang.UnsupportedOperationException (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 3.733 secs
I cannot use this property. I can use maxHeapSize = "2g" as stated in this question . I would like to use it to set the heap size to the minimum amount.
Below is a github project that recreates this situation.
+3
source to share