问题描述
我的gradle已经建立和运行。我的的build.gradle
有内部定义的2个任务:
I have gradle set up and running. My build.gradle
has 2 tasks defined inside:
task setVersion() {
println('setVersion')
//...
}
task setIntegrationEnv() {
println('setIntegrationEnv')
//...
}
当我运行
./gradlew clean
gradle这个台同时运行的任务 setVersion
和 setIntegrationEnv
,然后我所有的模块(<$ C $运行干净C>应用, cloud_module
),输出:
gradle runs both tasks setVersion
and setIntegrationEnv
and then it runs clean for all my modules (app
, cloud_module
) in that project, output:
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
setVersion
setIntegrationEnv
:cloud_module:clean
:app:clean
BUILD SUCCESSFUL
Total time: 14.18 secs
为什么出现这种情况,在这种行为定义?
Why this happens, where this behavior is defined?
推荐答案
请您提供全面的build.gradle
脚本?我会更容易帮助你。你可能弄错gradle这个的建立的相位的配置的阶段 - 这是这里的共同话题。
Could You please provide full build.gradle
script? I'd be much easier to help You. You've probably mistaken gradle build phase with configuration phase - it's a common topic here.
一般的规则是,code您希望在将要运行的构建的阶段应该添加为的动作的:
General rule is that code You'd like to be run at build phase should be added as an action:
task someTask << {
println 'runtime'
}
而code您想在运行的配置的阶段应该在任务体中添加:
while code You'd like to run at configuration phase should be added in task body:
task someTask {
println 'configuration
}
或一起:
task someTask {
println 'configuration'
doLast {
println 'runtime'
}
}
附加信息可以发现here, 和here.
这篇关于为什么gradle这个干净的任务开始的所有其他非默认的任务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!