// create a task depends on other project war
// put into the distribution gui folder the war.output.files
// the doLast gives visibility to the war.outputs.files
// after the depends on is complete
task otherProjectWar(dependsOn: ':OtherProject:war') {
doLast {
applicationDistribution.into("gui") {
from( project(':OtherProject').war.outputs.files )
}
}
}
// add depends on for distTar
distTar {
dependsOn otherProjectWar
...
}
3 回答
您需要为
war
任务的输出添加依赖项 . 默认情况下,ProjectDependency
只是将依赖项添加到该项目的默认配置中 .Edit :为了澄清,
compile
可能不是添加此依赖项的最佳配置,这只是一个示例 . 如果确实所有这个项目都在将依赖项聚合到单个分发归档中,那么配置可能无关紧要 .要将构建的war文件放入分发中,请添加distTar所依赖的任务 . 依赖于任务取决于其他项目的战争任务 . 获取输出文件并将它们放入分发中 . 关键是在doLast中进入/进入,因此依赖于其他项目战争在进入/发布之前完成 .
我认为正确的方法是将所需的任务输出包括在分发中 . 这是一个示例脚本,它将项目构建的jar添加到主分发中(对于war使用war输出而不是jar输出) .
运行分发任务然后正确解析zip和tar的依赖关系 .