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.
To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build. gradle file. This declares a dependency on an Android library module named "mylibrary" (this name must match the library name defined with an include: in your settings.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With