1

我即将在io.freefair.lombok我的 gradle 项目中添加插件。

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

问题是,我必须添加这个脚本超过 20 多个存储库。如果我必须在这种情况下升级插件版本,每一个build.gradle都应该修改,这似乎不是一个好的解决方案。

我想知道我是否可以使用 BOM 管理插件版本。或者任何其他可能的解决方案都会有所帮助。

4

1 回答 1

1

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"
}
于 2021-05-10T06:44:30.677 回答