概要
JUnit 4.11 を依存ライブラリに加えると勝手に hamcrest-core が付いてきちゃうのだけど、 hamcrest-core じゃなくて hamcrest-all を使いたいという場合の dependencies の書き方をメモっておく。
build.gradle の記述例
apply plugin: 'java'
sourceCompatibility = 1.5
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
testCompile (group: 'junit', name: 'junit', version: '4.11') {
// これで hamcrest-core の依存を除外する
exclude module: 'hamcrest-core'
}
// 改めて hamcrest-all の依存を追加する
testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3'
}