Spring Boot 2.3.x の Web アプリを 2.4.x へバージョンアップする ( その7 )( SpotBugs を 4.1.1 → 4.2.1 へバージョンアップする )
概要
記事一覧はこちらです。
Spring Boot 2.3.x の Web アプリを 2.4.x へバージョンアップする ( その6 )( Error Prone を 2.4.0 → 2.5.1 へバージョンアップする ) の続きです。
- 今回の手順で確認できるのは以下の内容です。
- SpotBugs を 4.1.1 → 4.2.1 へバージョンアップします。
- SpotBugs 4.2.1 に対応する spotbugs-gradle-plugin のバージョンは 4.6.1 なので、このバージョンにします。対応バージョンは SpotBugs version mapping に記載されています。
- これまで build.gradle 内に SpotBugs のバージョン番号を直接記述していましたが、Refer the version in the build script に
${spotbugs.toolVersion.get()}
で取れるとの記述がありましたので、今回からこの方法に切り替えます。
参照したサイト・書籍
SpotBugs
https://spotbugs.github.io/spotbugs / spotbugs
https://github.com/spotbugs/spotbugsspotbugs / spotbugs-gradle-plugin
https://github.com/spotbugs/spotbugs-gradle-pluginThe following classes needed for analysis were missing for method names
https://github.com/find-sec-bugs/find-sec-bugs/issues/440ati90ati / bugreport-spotbugs-gradle-plugin-logging
https://github.com/ati90ati/bugreport-spotbugs-gradle-plugin-logging
目次
手順
build.gradle を変更する
plugins { id "java" id "eclipse" id "idea" id "org.springframework.boot" version "2.4.3" id "io.spring.dependency-management" version "1.0.11.RELEASE" id "groovy" id "checkstyle" id "com.github.spotbugs" version "4.6.1" id "pmd" id "net.ltgt.errorprone" version "1.3.0" id "com.gorylenko.gradle-git-properties" version "2.2.4" id "org.seasar.doma.codegen" version "1.2.1" } .......... spotbugs { toolVersion = "${spotbugs.toolVersion.get()}" ignoreFailures = true spotbugsTest.enabled = false } spotbugsMain { reports { html { enabled = true stylesheet = "color.xsl" } } } .......... dependencies { def jdbcDriver = "org.postgresql:postgresql:42.2.19" def spockVersion = "1.3-groovy-2.5" def domaVersion = "2.45.0" def lombokVersion = "1.18.18" def errorproneVersion = "2.5.1" def powermockVersion = "2.0.9" .......... // for SpotBugs spotbugs(configurations.spotbugsPlugins.dependencies) annotationProcessor("com.github.spotbugs:spotbugs-annotations:${spotbugs.toolVersion.get()}") spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0") }
- plugins block の以下の点を変更します。
id "com.github.spotbugs" version "4.5.0"
→id "com.github.spotbugs" version "4.6.1"
- spotbugs block の以下の点を変更します。
toolVersion = "4.1.1"
→toolVersion = "${spotbugs.toolVersion.get()}"
- dependencies block の以下の点を変更します。
def spotbugsVersion = "4.1.1"
を削除します。spotbugs("com.github.spotbugs:spotbugs:${spotbugsVersion}")
→spotbugs(configurations.spotbugsPlugins.dependencies)
compileOnly("com.github.spotbugs:spotbugs-annotations:${spotbugsVersion}")
→annotationProcessor("com.github.spotbugs:spotbugs-annotations:${spotbugs.toolVersion.get()}")
spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1")
→spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.11.0")
Gradle Tool Window の左上にある「Refresh all Gradle projects」ボタンをクリックして更新した後、clean タスク実行 → Rebuild Project 実行 → build タスクを実行すると BUILD SUCCESSFUL のメッセージが出力されました。
履歴
2021/03/04
初版発行。