Spring Boot 2.0.x の Web アプリを 2.1.x へバージョンアップする ( その18 )( Gradle を 5.2.1 → 5.3.1 へ、Spock を 1.2 → 1.3 へ、JUnit 5 を 5.4.0 → 5.4.1 へバージョンアップする )
概要
記事一覧はこちらです。
Spring Boot 2.0.x の Web アプリを 2.1.x へバージョンアップする ( その17 )( JDK 11 環境下で error-prone を復活させる ) の続きです。
- 今回の手順で確認できるのは以下の内容です。
参照したサイト・書籍
Gradle Docs 5.3.1 - Gradle Release Notes
https://docs.gradle.org/5.3.1/release-notes.htmlJUnit 5 Release Notes - 5.4.1
https://junit.org/junit5/docs/current/release-notes/index.html#release-notes-5.4.1
目次
手順
Gradle を 5.2.1 → 5.3.1 へバージョンアップする
build.gradle の wrapper タスクの記述を以下のように変更します。
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
wrapper {
gradleVersion = "5.3.1"
distributionType = Wrapper.DistributionType.ALL
}
- Gradle Docs 5.3.1 - Gradle Release Notes に
sourceCompatibility = JavaVersion.VERSION_11
という記述を見つけたので、この書き方に修正します。sourceCompatibility = 11
→sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = 11
→targetCompatibility = JavaVersion.VERSION_11
gradleVersion = "5.2.1"
→gradleVersion = "5.3.1"
に変更します。
コマンドプロンプトから gradlew wrapper --gradle-version=5.3.1
、gradlew --version
コマンドを実行します。
gradle/wrapper/gradle-wrapper.properties は以下の内容になります。
distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists
gradlew、gradlew.bat の DEFAULT_JVM_OPTS の設定が -Xmx64m に戻っているので -Xmx4096m に変更します。
Gradle Tool Window の左上にある「Refresh all Gradle projects」ボタンをクリックして更新します。
clean タスク実行 → Rebuild Project 実行 → build タスクを実行すると "BUILD SUCCESSFUL" のメッセージが表示されました。
Spock を 1.2 → 1.3 へ、JUnit 5 を 5.4.0 → 5.4.1 へバージョンアップする
build.gradle の以下の点を変更します。
dependencyManagement { imports { // mavenBom は以下の URL のものを使用する // https://repo.spring.io/release/org/springframework/boot/spring-boot-starter-parent/2.1.2.RELEASE/ // bomProperty に指定可能な property は以下の URL の BOM に記述がある // https://repo.spring.io/release/org/springframework/boot/spring-boot-dependencies/2.1.2.RELEASE/spring-boot-dependencies-2.1.2.RELEASE.pom mavenBom(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES) { // Spring Boot の BOM に定義されているバージョンから変更する場合には、ここに以下のように記述する // bomProperty "thymeleaf.version", "3.0.9.RELEASE" } mavenBom("org.junit:junit-bom:5.4.1") } } dependencies { def jdbcDriver = "org.postgresql:postgresql:42.2.5" def spockVersion = "1.3-groovy-2.5" def domaVersion = "2.24.0" def lombokVersion = "1.18.6" def errorproneVersion = "2.3.3" def powermockVersion = "2.0.0" def spotbugsVersion = "3.1.11" // dependency-management-plugin によりバージョン番号が自動で設定されるもの // Appendix F. Dependency versions ( https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-dependency-versions.html ) 参照 implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-thymeleaf") implementation("org.thymeleaf.extras:thymeleaf-extras-springsecurity5") implementation("org.springframework.boot:spring-boot-starter-data-jpa") implementation("org.springframework.boot:spring-boot-starter-freemarker") implementation("org.springframework.boot:spring-boot-starter-mail") implementation("org.springframework.boot:spring-boot-starter-security") implementation("org.springframework.boot:spring-boot-starter-data-redis") implementation("org.springframework.boot:spring-boot-starter-amqp") implementation("org.springframework.boot:spring-boot-starter-actuator") runtimeOnly("org.springframework.boot:spring-boot-devtools") compileOnly("org.springframework.boot:spring-boot-configuration-processor") implementation("org.springframework.session:spring-session-data-redis") implementation("org.springframework.retry:spring-retry") implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml") implementation("org.apache.commons:commons-lang3") implementation("org.codehaus.janino:janino") implementation("io.micrometer:micrometer-registry-prometheus") testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.springframework.security:spring-security-test") testImplementation("org.yaml:snakeyaml") // dependency-management-plugin によりバージョン番号が自動で設定されないもの、あるいは最新バージョンを指定したいもの runtimeOnly("${jdbcDriver}") implementation("com.integralblue:log4jdbc-spring-boot-starter:1.0.2") implementation("org.simpleframework:simple-xml:2.7.1") implementation("com.univocity:univocity-parsers:2.8.1") implementation("com.google.guava:guava:27.1-jre") implementation("org.flywaydb:flyway-core:5.2.4") testImplementation("org.dbunit:dbunit:2.6.0") testImplementation("com.icegreen:greenmail:1.5.10") testImplementation("org.assertj:assertj-core:3.12.2") testImplementation("com.jayway.jsonpath:json-path:2.4.0") testImplementation("org.jsoup:jsoup:1.11.3") testImplementation("cglib:cglib-nodep:3.2.10") testImplementation("org.spockframework:spock-core:${spockVersion}") testImplementation("org.spockframework:spock-spring:${spockVersion}") // for lombok // testAnnotationProcessor、testCompileOnly を併記しなくてよいよう configurations で設定している annotationProcessor("org.projectlombok:lombok:${lombokVersion}") compileOnly("org.projectlombok:lombok:${lombokVersion}") // for Doma annotationProcessor("org.seasar.doma:doma:${domaVersion}") implementation("org.seasar.doma:doma:${domaVersion}") domaGenRuntime("org.seasar.doma:doma-gen:${domaVersion}") domaGenRuntime("${jdbcDriver}") // for JUnit 5 // junit-jupiter で junit-jupiter-api, junit-jupiter-params, junit-jupiter-engine の3つが依存関係に追加される testCompile("org.junit.jupiter:junit-jupiter") testRuntime("org.junit.platform:junit-platform-launcher") // for Error Prone ( http://errorprone.info/ ) errorprone("com.google.errorprone:error_prone_core:${errorproneVersion}") compileOnly("com.google.errorprone:error_prone_annotations:${errorproneVersion}") // PowerMock testImplementation("org.powermock:powermock-module-junit4:${powermockVersion}") testImplementation("org.powermock:powermock-api-mockito2:${powermockVersion}") // for SpotBugs compileOnly("com.github.spotbugs:spotbugs:${spotbugsVersion}") compileOnly("net.jcip:jcip-annotations:1.0") compileOnly("com.github.spotbugs:spotbugs-annotations:${spotbugsVersion}") testImplementation("com.google.code.findbugs:jsr305:3.0.2") }
- dependencyManagement block の以下の点を変更します。
mavenBom("org.junit:junit-bom:5.4.0")
→mavenBom("org.junit:junit-bom:5.4.1")
に変更します。
- dependencies block の以下の点を変更します。
def spockVersion = "1.2-groovy-2.5"
→def spockVersion = "1.3-groovy-2.5"
に変更します。def domaVersion = "2.23.0"
→def domaVersion = "2.24.0"
に変更します。implementation("com.google.guava:guava:27.0.1-jre")
→implementation("com.google.guava:guava:27.1-jre")
に変更します。testImplementation("com.icegreen:greenmail:1.5.9")
→testImplementation("com.icegreen:greenmail:1.5.10")
に変更します。testImplementation("org.assertj:assertj-core:3.11.1")
→testImplementation("org.assertj:assertj-core:3.12.2")
に変更します。
Gradle Tool Window の左上にある「Refresh all Gradle projects」ボタンをクリックして更新します。
clean タスク実行 → Rebuild Project 実行 → build タスクを実行すると "BUILD SUCCESSFUL" のメッセージが表示されました。
履歴
2019/03/30
初版発行。