やったら動いた程度なので実際に使用する場合は注意してください。
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
を指定する。
buildSrc/src/main/groovy/asdgradle.java-common-conventions.gradle
dependencies {
implementation platform("org.springframework.boot:spring-boot-dependencies:2.4.4");
...
上手くいかなかったこと
最初は以下のようにxxx.java-common-conventions.gradle
にspring-bootのpluginを定義すれば良いのかな、と思った。
buildSrc/src/main/groovy/xxx.java-common-conventions.gradle
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