gradle:在另一个项目下调用成绩文件

时间:2019-05-24 23:11:50

标签: gradle

5.4.1级

/project-foo/build.gradle


/project-bar/settings.gradle   
/project-bar/common-gradle/build-hello.gradle
/project-bar/common-gradle/build-world.gradle 

project-bar / common-gradle不是项目目录,而是仅包含常用的gradle文件。

project-foo / build.gradle如下调用project-bar下的build-hello.gradle:

task build_hello(type: GradleBuild) {
    dir = "${rootProject.buildDir}/build-hello"
    buildFile = file("/project-bar/common-gradle/build-hello.gradle")
    ...
}  

assemble.dependsOn build_hello

在构建project-foo时,出现错误:

Build file '/project-bar/common-gradle/hello.gradle' is not 
part of the build defined by settings file
'/project-bar/settings.gradle'. If this is an unrelated build, 
it must have its own settings file.

如果/project-bar/settings.gradle被删除,则构建project-foo即可。错误消息是什么意思?

是否应在不是项目目录的common-gradle目录下创建settings.gradle?它的内容是什么?

0 个答案:

没有答案