我需要在使用Gradle构建时将默认JVM选项添加到我的jar包中。 从文档中得知,我需要设置以下内容:
applicationDefaultJvmArgs = ["-Djavafx.embed.singleThread=true"]
我在Gradle方面没有太多经验,并且编写build.gradle文件的开发人员编写的方式与大多数网站给出的示例不同。
这是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')
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
task wrapper(type: Wrapper) {
gradleVersion = '2.2.1'
}
我不知道该把参数放在哪里。我尝试将它们放置在不同的位置,但总是会遇到以下问题:
A problem occurred evaluating root project 'placeholder'.
> No such property: applicationDefaultJvmArgs for class: org.gradle.api.tasks.bundling.Jar_Decorated
非常感谢,Jhonny
System.setproperty("javafx.embed.singleThread", "true")
的语句,但是你需要确保该语句在系统属性被访问之前得到执行。 - KKishore