How to declare common dependencies in multimodule gradle project on parent folder

放肆的年华 提交于 2021-01-03 07:12:10

问题


I've multi-module gradle project. Let's say project parent has modules module1 and module2.

I have included both the modules in settings.gradle in the parent project as well.

When I declare the common dependencies in build.gradle of parent project, both the project is not compiling but when I add the dependencies in build.gradle of each module then the modules are compiling successfully.

Any Idea how can I do this.


回答1:


You can declare dependencies for all modules in your project using the allprojects statement in your parent module. This is the essential way of doing so in your parent build.gradle file:

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'
    }
}

Check this and this answer for more insight on the configuration point of a multi project.
Also have a look at the Gradle documentation about this topic for a deep dive.



来源:https://stackoverflow.com/questions/50106128/how-to-declare-common-dependencies-in-multimodule-gradle-project-on-parent-folde

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!