我有一个包含两个Java库模块“ A”和“ B”的多项目构建。 'B'对模块'A'有依赖性:
dependencies {
api ':A'
}
现在,我想编写一个提供自定义任务“ myGenerator”的自定义插件。在编译模块“ B”中的任何类(任务compileJava)之前,但在组装模块“ A”之后,“ myGenerator”必须运行(“ myGenerator”将实现需要模块“ A”的某些资源的代码生成器)。
如何配置任务“ myGenerator”?如果我说
compileJava.dependsOn myGenerator
并在模块'B'中运行gradle assemble
,在组装模块'A'之前仍要执行'myGenerator'。
我必须以某种方式将“ myGenerator”配置为对模块“ A”的配置“ api”具有依赖性。我该怎么办?
答案 0 :(得分:0)
您只从句子中表达了一种依存关系:
'myGenerator'必须在编译模块'B'中的所有类(任务compileJava)之前但在组装模块'A'之后运行
您需要表达另一个:
myGenerator.dependsOn project(':A').jar // or the relevant assembly task of your build