Hello world
Hello world

Reputation: 353

Managing gradle plugin version with BOM

I'm about to add io.freefair.lombok plugin to my gradle projects.

plugins {
    id "io.freefair.lombok" version "5.3.3.3"
}

Problem is, I have to add this script more than 20+ repositories. If I have to upgrade plugin version within this scenario, every single build.gradle should be modified and it doesn't seem to be a good solution.

I wonder if I can manage plugin version with BOM. Or any other possible solution would be helpful.

Upvotes: 1

Views: 1105

Answers (1)

Thomas K.
Thomas K.

Reputation: 6770

If you use Gradle 6.9+ or 7.0+, you could use dynamic versions, such as latest.release or 5.+ (Declaring Versions and Ranges).

plugins {
    id "io.freefair.lombok" version "5.3.+"
}

Please be aware that io.freefair.lombok plugin versions are usually tied to specific Gradle versions. Should you use the Gradle Wrapper, using latest.release without upgrading Gradle may break your builds.

This approach could be combined with a custom Gradle plugin or init script. For example, you could have a custom plugin that depends on a curated list of maintained plugins required for your builds. When your plugin gets applied, it should be able to apply other plugins as well.

plugins {
    id "com.company.my-gradle-plugin" version "latest.release"
}

Upvotes: 1

Related Questions