Spring Boot 2.2.x の Web アプリを 2.3.x へバージョンアップする ( その8 )( SpotBugs を 4.0.0-beta4 → 4.1.1 へバージョンアップする )
概要
記事一覧はこちらです。
Spring Boot 2.2.x の Web アプリを 2.3.x へバージョンアップする ( その7 )( Error Prone を 2.3.4 → 2.4.0 へバージョンアップする ) の続きです。
- 今回の手順で確認できるのは以下の内容です。
- SpotBugs を 4.0.0-beta4 → 4.1.1 へバージョンアップします。
- SpotBugs の最新バージョンは 4.1.2 ですが、spotbugs-gradle-plugin の最新バージョン 4.5.0 に対応する SpotBugs のバージョンは 4.1.1 なので 4.1.1 にします。対応バージョンは SpotBugs version mapping に記載されています。
参照したサイト・書籍
SpotBugs
https://spotbugs.github.io/spotbugs / spotbugs
https://github.com/spotbugs/spotbugsspotbugs / spotbugs-gradle-plugin
https://github.com/spotbugs/spotbugs-gradle-plugin
目次
手順
build.gradle を変更する
コメントアウトしていたのを解除して、以下の点を変更します。
plugins { id "java" id "eclipse" id "idea" id "org.springframework.boot" version "2.3.2.RELEASE" id "io.spring.dependency-management" version "1.0.9.RELEASE" id "groovy" id "checkstyle" id "com.github.spotbugs" version "4.5.0" id "pmd" id "net.ltgt.errorprone" version "1.2.1" id "com.gorylenko.gradle-git-properties" version "2.2.3" } .......... spotbugs { toolVersion = "4.1.1" ignoreFailures = true spotbugsTest.enabled = false } spotbugsMain { reports { html { enabled = true stylesheet = "color.xsl" } } } .......... dependencies { def jdbcDriver = "org.postgresql:postgresql:42.2.14" def spockVersion = "1.3-groovy-2.5" def domaVersion = "2.26.0" def lombokVersion = "1.18.12" def errorproneVersion = "2.4.0" def powermockVersion = "2.0.7" def spotbugsVersion = "4.1.1" .......... // for SpotBugs spotbugs("com.github.spotbugs:spotbugs:${spotbugsVersion}") compileOnly("com.github.spotbugs:spotbugs-annotations:${spotbugsVersion}") spotbugsPlugins("com.h3xstream.findsecbugs:findsecbugs-plugin:1.10.1") }
- plugins block の以下の点を変更します。
id "com.github.spotbugs" version "3.0.0"
→id "com.github.spotbugs" version "4.5.0"
- spotbugs block の以下の点を変更します。
toolVersion = "4.0.0-beta4"
→toolVersion = "4.1.1"
effort = "max"
を削除します。
tasks.withType(com.github.spotbugs.SpotBugsTask) {
→spotbugsMain {
に変更します。- spotbugsMain block の以下の点を変更します。
xml.enabled = false
を削除します。reports { ... }
→reports { html { ... } }
stylesheet = resources.text.fromArchiveEntry(configurations.spotbugsStylesheets, "color.xsl")
→stylesheet = "color.xsl"
- dependencies block の以下の点を変更します。
def spotbugsVersion = "4.0.0-beta4"
→def spotbugsVersion = "4.1.1"
compileOnly("com.github.spotbugs:spotbugs:${spotbugsVersion}")
→spotbugs("com.github.spotbugs:spotbugs:${spotbugsVersion}")
exclude group: "pull-parser", module: "pull-parser"
を削除します。4.1.1 では依存関係からなくなっていました。- 以下の3行も削除します。
compileOnly("net.jcip:jcip-annotations:1.0")
testImplementation("com.google.code.findbugs:jsr305:3.0.2")
spotbugsStylesheets("com.github.spotbugs:spotbugs:${spotbugsVersion}")
Gradle Tool Window の左上にある「Refresh all Gradle projects」ボタンをクリックして更新した後、clean タスク実行 → Rebuild Project 実行 → build タスクを実行すると "BUILD SUCCESSFUL" のメッセージが出力されました。
正式バージョンになって設定がすっきりしました。
履歴
2020/08/23
初版発行。