我有一个包含两个模块的 gradle 项目。
第一个模块 (A) 生成第二个模块 (B) 使用的存档。我已经定义了 settings.gradle
文件,以便在 B 之前看到 A。
在 A 的末尾,调用了一个 install
任务,这将使存档对 B 可用,但是 install
任务直到 < em>所有模块构建。
当我使用 A 的构建文件,或设置构建命令 -p
时,它仍会尝试为项目 B 查找依赖项。我不想这样做!
我如何设置它以便模块 B 完全等待模块 A 完成?
最佳答案
I've defined the settings.gradle file so that A is seen before B.
顺序在这里无关紧要。
At the end of A, there is an install task that is called which will make the archive available for B
处理此问题的正确方法是通过项目依赖 使 A 的输出对 B 可用。在最简单的情况下,B 的 build.gradle
将包含以下内容:
dependencies {
compile project(":A") // could be something other than 'compile'
}
When I use A's build file, or set the build command -p it will still try to find dependencies for project B.
很可能您的某个构建脚本存在问题,即它在本应在执行阶段完成的配置阶段确实有效。 p>
How can I set this up so that module B will wait completely for module A to finish?
没有什么好办法。 Gradle 执行任务图,而不是项目列表。只要任务依赖关系正确,前者就没有缺点,只有优点。通常,Gradle 可以自动找出任务依赖关系(尤其是项目之间)。
关于module - Gradle 模块执行顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17890418/