We use a BOM to share our dependency management in MyCompany.
It is defined as a Maven POM. Here is a minimal example:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.common</groupId>
<artifactId>common-java</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<properties>
<spring-boot.version>2.4.0</spring-boot.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
It is then used from Gradle projects.
Although this works for code dependencies, I'd like to find out a way to use it from plugin management.
For now, we define in settings.gradle.kts:
pluginManagement {
val springBootVersion: String by settings
plugins {
id("org.springframework.boot") version(springBootVersion)
}
}
springBootVersion being defined in the gradle.properties.
This is an issue to me because Spring version is defined both:
- in the shared BOM;
- in each project's plugin management.
How can I access to that BOM from Gradle's plugin management? And if I can't, what is a good don't-repeat-yourself practice to do so?