我有多模块gradle项目。假设项目parent
包含模块module1
和module2
。
我在父项目的settings.gradle
中也包含了这两个模块。
当我在父项目的build.gradle
中声明公共依赖项时,项目都没有编译,但是当我在每个模块的build.gradle
中添加依赖项时,模块就会成功编译。
任何想法我该怎么做。
答案 0 :(得分:1)
您可以使用父模块中的allprojects语句为项目中的所有模块声明依赖项。这是在父build.gradle文件中执行此操作的基本方法:
allprojects {
// Plugins can go here, example:
apply plugin: 'java'
dependencies {
// Dependencies go here, example:
compile group: 'org.apache.shiro', name: 'shiro-core', version: '1.4.0'
}
}
检查this和this答案,了解有关多项目配置点的更多信息 另请参阅有关此主题的Gradle documentation进行深入研究。