I use the gradle application plugin to generate the application folder.
The installApp
task provides a start script for me, but I have no idea how to set the jvm args from build.gradle
.
Some jvm args I needed, such as file.encoding
. I just modify the start script to set the DEFAULT_JVM_OPTS
variable
#!/usr/bin/env bash
##############################################################################
##
## MuzeeS3Deployer start up script for UN*X
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and MUZEE_S_DEPLOYER_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=" -Dfile.encoding=utf-8 "
If the args not set, my console cannot show messages well:
qty:MuzeeS3Deployer qrtt1$ ./build/install/MuzeeS3Deployer/bin/MuzeeS3Deployer d
2012/10/14 #U###12:02:03 SyncCommand main
ĵ#i: no aws credentials found at /Users/qrtt1/AwsCredentials.properties
When I set the encoding:
qty:MuzeeS3Deployer qrtt1$ ./build/install/MuzeeS3Deployer/bin/MuzeeS3Deployer d
2012/10/14 下午 12:04:19 SyncCommand main
警告: no aws credentials found at /Users/qrtt1/AwsCredentials.properties
I got the solution from @Peter. Finally, I make a minor changes to the scripts:
startScripts {
doLast {
unixScript.text = unixScript.text.replace('DEFAULT_JVM_OPTS=""', 'DEFAULT_JVM_OPTS="-Dfile.encoding=utf-8"')
windowsScript.text = windowsScript.text.replace('DEFAULT_JVM_OPTS=', 'DEFAULT_JVM_OPTS="-Dfile.encoding=utf-8"')
}
}
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.
Basically, Gradle JVM equals Project SDK. If the project's SDK equals JRE then IntelliJ IDEA will use the same steps as in opening an existing Gradle project. If there is a Gradle wrapper, then IntelliJ IDEA will use the most compatible existing Gradle version on the machine.
Support for JVM arguments was added in Gradle 1.7: https://docs.gradle.org/current/userguide/application_plugin.html#configureApplicationDefaultJvmArgs
For example, for setting file.encoding
, you can do:
applicationDefaultJvmArgs = ['-Dfile.encoding=utf-8']
There is currently no special support for setting DEFAULT_JVM_OPTS
. However, you can do something like:
startScripts {
doLast {
unixScript.text = unixScript.text.replace('DEFAULT_JVM_OPTS=""', 'DEFAULT_JVM_OPTS="-Dfile.encoding=utf-8"')
}
}
You may want to do something similar for windowsScript
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With