2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

gradleのbuildSrc下でspring-bootのversionを指定

Posted at

やったら動いた程度なので実際に使用する場合は注意してください。

gradleは少なくとも6.8.3gradle 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
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?