Spring Boot 1.2.x の Web アプリを 1.3.x へバージョンアップする ( その3 )( build.gradle 修正後の Rebuild で出た Warning を解消する )
概要
Spring Boot 1.2.x の Web アプリを 1.3.x へバージョンアップする ( その2 )( build.gradle の修正 ) の続きです。
- 今回の手順で確認できるのは以下の内容です。
- build.gradle 修正後の Rebuild Project 実行時に出た Warning の解消。
参照したサイト・書籍
目次
- Warning:Groovyc: The global transform for class groovy.grape.GrabAnnotationTransformation is defined in both jar
- mockitのmockit.NonStrictExpectationsは非推奨になりました
- 次回は。。。
手順
Warning:Groovyc: The global transform for class groovy.grape.GrabAnnotationTransformation is defined in both jar
メッセージを見ると groovy と groovy-all の両方で groovy.grape.GrabAnnotationTransformation が定義されているという内容です。
Project View でライブラリ一覧を表示すると確かに groovy も groovy-all も表示されています。
groovy-all がなくなればいいのかなと思い build.gradle の dependencies タスクから testCompile("org.codehaus.groovy:groovy-all")
を削除して更新してみましたが、これだけだとまだ groovy, groovy-all どちらも表示されたままでした。。。
Google でいろいろ検索してみると以下の github の issue を見つけました。
- https://github.com/spockframework/spock/issues/52
- https://github.com/spockframework/spock/issues/508
spock のライブラリを testCompile で指定しているところで exclude module: "groovy-all"
を記述すれば groovy-all がなくなりそうですので試してみます。
build.gradle を以下のように修正します。
dependencies { def jdbcDriver = "org.postgresql:postgresql:9.4.1208" // dependency-management-plugin によりバージョン番号が自動で設定されるもの // Appendix A. Dependency versions ( http://docs.spring.io/platform/docs/current/reference/htmlsingle/#appendix-dependency-versions ) 参照 compile("org.springframework.boot:spring-boot-starter-web") compile("org.springframework.boot:spring-boot-starter-thymeleaf") compile("org.thymeleaf.extras:thymeleaf-extras-springsecurity4") compile("org.springframework.boot:spring-boot-starter-data-jpa") compile("org.springframework.boot:spring-boot-starter-velocity") compile("org.springframework.boot:spring-boot-starter-mail") compile("org.springframework.boot:spring-boot-starter-security") compile("org.springframework.boot:spring-boot-starter-redis") compile("org.springframework.boot:spring-boot-starter-amqp") compile("org.springframework.session:spring-session") compile("org.codehaus.janino:janino") compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310") compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml") testCompile("org.springframework.boot:spring-boot-starter-test") testCompile("org.springframework.security:spring-security-test") testCompile("org.yaml:snakeyaml") testCompile("org.spockframework:spock-core") { exclude module: "groovy-all" } testCompile("org.spockframework:spock-spring") { exclude module: "groovy-all" } // dependency-management-plugin によりバージョン番号が自動で設定されないもの、あるいは最新バージョンを指定したいもの runtime("${jdbcDriver}") compile("org.seasar.doma:doma:2.8.0") compile("org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16") compile("org.apache.commons:commons-lang3:3.4") compile("org.projectlombok:lombok:1.16.8") compile("com.google.guava:guava:19.0") compile("org.simpleframework:simple-xml:2.7.1") compile("com.univocity:univocity-parsers:2.1.1") compile("org.thymeleaf.extras:thymeleaf-extras-java8time:2.1.0.RELEASE") testCompile("org.dbunit:dbunit:2.5.1") testCompile("com.icegreen:greenmail:1.5.0") testCompile("org.assertj:assertj-core:3.4.1") testCompile("com.jayway.jsonpath:json-path:2.2.0") testCompile("org.jmockit:jmockit:1.23") // for Doma-Gen domaGenRuntime("org.seasar.doma:doma-gen:2.8.0") domaGenRuntime("${jdbcDriver}") }
testCompile("org.codehaus.groovy:groovy-all")
を削除します。- spock-core, spock-spring を指定しているところで
exclude module: "groovy-all"
を記述します。
Gradle projects View の左上にある「Refresh all Gradle projects」ボタンをクリックして更新すると、今度は groovy-all が消えて groovy だけ表示されるようになりました。
clean タスク実行 → Rebuild Project 実行 を試してみると、Warning:Groovyc: The global transform for class groovy.grape.GrabAnnotationTransformation is defined in both jar
の Warning が表示されなくなりました。
mockitのmockit.NonStrictExpectationsは非推奨になりました
JMockit の Development history ( http://jmockit.org/changes.html ) を見ると、Version 1.23 (Apr 24, 2016) に Deprecated the NonStrictExpectations class
と記載されています。またその後に Existing tests should use Expectations instead.
と書かれており、Expectations に変えればよいようです。
既存のテストで NonStrictExpectations を使用しているところを全て Expectations に変更します。変更対象は以下のテストです。
- src/main/java/ksbysample/webapp/lending/helper/library/LibraryHelperTest.java
- src/main/java/ksbysample/webapp/lending/web/booklist/BooklistServiceTest.java
clean タスク実行 → Rebuild Project 実行 を試してみると、何の Warning も出なくなりました。
次回は。。。
Project View の src/test から Run 'All Tests' with Coverage を実行するとやっぱり変わらずテストが失敗したままですので、失敗の原因を取り除いていきます。
ソースコード
履歴
2016/05/17
初版発行。