java - How do I add default JVM arguments with Gradle -


i need add default jvm options jar, when build gradle. documentation got have set:

applicationdefaultjvmargs = ["-djavafx.embed.singlethread=true"] 

i have not experience gradle , developer wrote build.gradle file wrote different websites give examples.

here build.gradle:

apply plugin: 'java' apply plugin: 'eclipse'  version = '0.1'  repositories {     mavencentral() }  dependencies {     testcompile group: 'junit', name: 'junit', version: '4.+'     compile 'placeholder' }  task release(type: jar) {     manifest {         attributes("implementation-title": "placeholder",                 "implementation-version": version,                 'main-class': 'placeholder.application')     }     { configurations.compile.collect { it.isdirectory() ? : ziptree(it) } }      jar }  task wrapper(type: wrapper) {     gradleversion = '2.2.1' } 

i don't know put arguments. tried putting them in different locations, get:

a problem occurred evaluating root project 'placeholder'. > no such property: applicationdefaultjvmargs class: org.gradle.api.tasks.bundling.jar_decorated 

much thanks, jhonny

from top of head can think of 2 options:

option1: @ethan said, it'll work:

package placeholder;  //your imports  public class application{   static {       system.getproperties().set("javafx.embed.singlethread", "true");     }   // code   public static void main(string... args){     //your code   } } 

option 2: use application plugin + default jvm values

build.gradle:

apply plugin: 'application' //your code applicationdefaultjvmargs = ["-djavafx.embed.singlethread=true"] 

now can run code 2 ways:

from gradle

$gradle run 

from distribution(script). generated script application plugin provide:

$gradle clean build distzip 

then gradle generate zip file somewhere under ${your.projectdir}/build. find zip unzip , under /bin you'll find ${yourproject}.bat , ${yourproject} executables. 1 linux/mac/unix (${yourproject}) other 1 windows (${yourproject.bat})


Comments