开发者

How to pass a property to a dependency?

Gradle jettyRun task has the daemon property which I want to be false when I start the app, but true when I have it as a dependency of the acceptance-test (fastend2end) task.

task fastend2end(type: Test, dependsOn: jettyRun) {
    description = "Runs the end to end tests"
    testClassesDir = sourceSets.end2end.classesDir
    classpath = s开发者_运维知识库ourceSets.end2end.runtimeClasspath
}

Can I specify that for the fastend2end daemon should be true? However, when I run jettyRun by itself I want the daemon property to be false.


You can't do this directly. But you can use the following snippet to set the daemon property if the fastend2end task is in your execution graph:

gradle.taskGraph.whenReady {graph ->
    if (graph.hasTask(fastend2end)) {
        jettyRun.daemon = true
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜