This Gradle plugin generates a bill of materials (BOM) file for multi-module projects. Next BOM can be imported in other projects and efficiently ease working with versioning multi-project dependency. The plugin allows excluding modules & including external dependencies. You can configure multiple Maven publications or use default one.
Attention! A module to be included in a BOM has to have Maven Publish Plugin applied and configured.
- Usage
- License
- Copyright
Create a new module for a BOM generation with a build.gradle
file. If you don't know how to create a module for
multi-module project, check out this official guide.
plugins {
id("io.github.gradlebom.generator-plugin") version "1.0.0.Final"
}
group = "org.example"
version = "1.0.0"
plugins {
id 'io.github.gradlebom.generator-plugin' version '1.0.0.Final'
}
group = 'org.example'
version = '1.0.0'
Next include the new module in settings.gradle
. Finally, build whole multi-module project.
If you don't know, how to configure MavenPublication
,
check out the official documentation of Maven Publish Plugin.
By default, you don't need to configure MavenPublication
on your own. The plugin configures a basic publication
with name bomJava
. It uses the project name as artifactId
.
You can configure publications on your own. The plugin collects all defined Maven publications and generates a BOM accordingly. The plugin applies Maven Publish Plugin, so you don't have to. An explicit publication configuration in Kotlin can look like this:
plugins {
id("io.github.gradlebom.generator-plugin") version "1.0.0.Final"
}
group = "org.example"
version = "0.0.1"
publishing {
publications {
create<MavenPublication>("maven") {
artifactId = "my-example-bom"
}
}
}
You can exclude modules from a BOM generation.
bomGenerator {
excludeProject("excluded-module")
}
You can add an external dependency that version will be included in a BOM.
bomGenerator {
includeDependency("org.other", "project", "1.0.0")
includeDependency("org.other:project:1.0.4")
}
A published BOM can be later used in different projects. See examples below or checkout official Gradle documentation here.
dependencies {
// import a BOM
implementation platform('org.example:module-bom:1.0.0')
// define dependencies from your multi-module project without versions
implementation 'org.example:module-data'
implementation 'org.example:module-web'
implementation 'org.example:module-logs'
}
dependencies {
// import a BOM
implementation(platform("org.example:module-bom:1.0.0"))
// define dependencies from your multi-module project without versions
implementation("org.example:module-data")
implementation("org.example:module-web")
implementation("org.example:module-logs")
}
<project>
<dependencyManagement>
<dependency>
<groupId>org.example</groupId>
<artifactId>module-bom</artifactId>
<version>1.0.0</version>
</dependency>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.example</groupId>
<artifactId>module-data</artifactId>
</dependency>
<dependency>
<groupId>org.example</groupId>
<artifactId>module-web</artifactId>
</dependency>
<dependency>
<groupId>org.example</groupId>
<artifactId>module-logs</artifactId>
</dependency>
</dependencies>
</project>
See LICENSE.
Copyright © 2021 Waldemar Panas