Gradle : Something like Maven Parent POM

(Jagan N) #1

In our company, many of the different projects use similar technology stack and will have many common features.
So, we want to maintain the common features, dependencies etc. in one common file and refer it in the other projects.
In maven, it is something like creating a separate maven project with the common dependency information and refer that in the other projects as .

I want to do something similar to the maven parent project in gradle, which can be used by all different projects.
I googled for that, but could not find a concise information on how to do that.
We are not allowed to use external thirdparty plugins.

It would be great if someone could explain it how to do that.

(Maksim Kostromin) #2

Just create commons module with all dependencies you need and use that as a dependency in your projects, like so:

// settings.gradle:
include “:commons”
include “:first-project-uses-commons”
include “:second-project-uses-commons”

// build.gradle
project(“:commons”) {
  dependencies {
    compile ....
project(“:first-project-uses-commons”) {
  dependencies {
    compile project(“:commons”)
project(“:second-project-uses-commons”) {
  dependencies {
    compile project(“:commons”)

If you need reuse some project in different projects not in same tree look at the documentation for included-builds

Gradle can propose u also other way to do same using configurations, such as allprojects or subptojects

(Oleksandr Gavenko) #3

You can maintain Maven BOM in Gradle:

(uklance) #4

Gradle 4.6 introduced core support for importing BOMs without the need for third party plugins