我的应用程序需要一个测试位置.我想通过系统属性来传递它.
在命令行上运行时,gradle不会传递该值:
./gradlew -Dfoo=bar clean cucumber
Java代码:
System.out.println("**foo(props):"+ System.getProperty("foo"));
输出:
**foo(props):null
我已经看过一些关于here的文档,但是当我尝试在gradle脚本中使用它时,出现以下错误:
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read 07001 for information on the replacement for dynamic properties.
Deprecated dynamic property: “systemProperties” on “task ‘:cucumber'”, value: “{jna.platform.library….”.
这是我的build.gradle的片段:
task cucumber() {
dependsOn assemble, compileTestJava
doLast {
systemProperties = System.getProperties()
javaexec {
main = "cucumber.api.cli.Main"
classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output
args = ['-f', 'pretty', '--glue', 'steps', 'src/test/resources']
}
}
}
如何通过Gradle将系统属性传递给应用程序?