如何将多个 gradle 脚本调用到其他 gradle 脚本中
我正在将 ant 脚本转换为 gradle。我在这个 gradle 脚本调用另外三个 gardle 脚本后进行了更改。当
<ant antfile="build.xml"
target="clean"/>
task buildclean(type: GradleBuild)<< {
buildFile ='build.gradle'
tasks['clean']
}
task buildelocket(type: GradleBuild)<< {
buildFile ='bussniess/build.gradle'
tasks['elocket']
}
我从同一 gradle 脚本下的其他任务调用 buildclean 任务时,它无法正常工作
task callingtasks <<{
tasks.buildclean.excute()
tasks.buildelocket.excute()
}
我如何调用多个 gradle 脚本进入其他 gradle 脚本
I am converting ant script to gradle.I have change following
<ant antfile="build.xml"
target="clean"/>
task buildclean(type: GradleBuild)<< {
buildFile ='build.gradle'
tasks['clean']
}
task buildelocket(type: GradleBuild)<< {
buildFile ='bussniess/build.gradle'
tasks['elocket']
}
this gradle script is calling three more other gardle scripts.When i called buildclean task from other task under same gradle script it is not working properly
task callingtasks <<{
tasks.buildclean.excute()
tasks.buildelocket.excute()
}
How do i can call more than one gradle scripts into other gradle script
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您的构建脚本存在两个问题:
删除“<<”在 buildclean 和 buildelelocket 任务中。 <<是 doLast{} 的快捷方式,但 GradleBuild 类型任务的 buidfile 和 task 属性应在配置阶段设置,而不是在执行阶段设置:
由于多种原因,您应该避免通过execute() 显式执行任务。尝试一下
I think there are two issues with your build scripts:
remove the "<<" in the buildclean and buildelocket task. << is a shortcut for doLast{} but buidfile and task property of tasks of type GradleBuild should be set in configurationphase not during execution phase:
For a number of reasons you should avoid executing tasks explicitly via execute(). Try