やったら動いた程度なので実際に使用する場合は注意してください。
gradleは少なくとも6.8.3はgradle initでsubproject有りを生成すると、共通定義はpluginに持つようになっている(詳細は https://docs.gradle.org/6.8.3/samples/sample_building_java_applications_multi_project.html )。従来はallprojectsとかsubprojectsを使用していたし、ぐぐるとこの例はたくさん出てくる。が、こちらの例はまだ少ないように見える。
このbuildSrc下のbuild.gradleでspring-bootの(bomの)versionを指定する方法について。
以下のようにspring-boot-dependenciesを指定する。
dependencies {
implementation platform("org.springframework.boot:spring-boot-dependencies:2.4.4");
...
上手くいかなかったこと
最初は以下のようにxxx.java-common-conventions.gradleにspring-bootのpluginを定義すれば良いのかな、と思った。
plugins {
id 'org.springframework.boot' version '2.4.4'
...
しかし、これはエラーになる。このpluginはprecompiledされるから、これに含まれるpluginのversionは書けない、ものらしい(良く分かって無い)
* What went wrong:
Invalid plugin request [id: 'org.springframework.boot', version: '2.4.4']. Plugin requests from precompiled scripts
must not include a version number. Please remove the version from the offending request and make sure the module
containing the requested plugin 'org.springframework.boot' is an implementation dependency