How do I specify memory settings for the application plugin’s start scripts? Nothing obvious stands out in StartScripts…
GRADLE-1456 explains how to do this.
I’m missing something, that issue seems to list all the ways that don’t work (and suggestions for how to make them work). Is there a quick example of how to do this?
Oh, I am sorry. I thought the ticket described the workaround as well. This post explains it.
FYI, this is what I ended up doing:
startScripts {
ext.jvmOpts = “-Xmx256m”
inputs.property(“jvmOpts”, { ext.jvmOpts }) // for incremental build to work properly
doLast {
def optsEnvVar = “DEFAULT_JVM_OPTS”
unixScript.text = unixScript.text.replace("$optsEnvVar=${’""’}", “$optsEnvVar=${’”’}$ext.jvmOpts${’"’}")
windowsScript.text = windowsScript.text.replace(“set $optsEnvVar=”, “set $optsEnvVar=$ext.jvmOpts”)
}
}
This is pretty ugly though. Why can’t the build script more naturally supply JVM_OPTS (or even take it from the run config)?
I heard Gradle 1.7 was supposed to have some improvement so that you don’t have to do search-and-replace. does anyone know if that was implemented?
thank you. the build complains about this variable though:
$ gradle build distZip
Creating properties on demand (a.k.a. dynamic properties) has been deprecated
and is
scheduled to be removed in Gradle 2.0.
Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html
for information on the replacement for dynamic properties.
Deprecated dynamic property: “applicationDefaultJvmArgs”
on “task ‘:launcher:startScripts’”, value: “-Xmx1024m”.
here’a a part of my build.gradle script:
apply plugin:‘application’
startScripts {
applicationDefaultJvmArgs = “-Xmx1024m”
doLast {
…
}
}
and the JMV args don’t end up in the start scripts. what is the right way to use that new variable? I’m using Gradle 1.8.