ポイント
- Gradle で Seasar の Fisshplate を扱うときは、repositories に maven の url として、https://www.seasar.org/maven/maven2/ を追加する必要がある。
- もちろんこれだけではダメで、通常使用する、jcenter() などの repositories も必要
Gradle で Seasar の Fisshplate を扱うときの最低限の build.gradle
plugins {
id 'java'
id 'application'
}
mainClassName = 'App'
dependencies {
compile group: 'org.seasar.fisshplate', name: 'fisshplate', version: '0.1.4'
}
repositories {
jcenter()
maven {
url "https://www.seasar.org/maven/maven2/"
}
}
repositories の maven の url に追加が必要なことをどうやって知るか?
[fisshplate maven] などで検索すると、次のページへとたどり着きます。
このページに次のようにあります。
Note: this artifact it located at Seasar repository (https://www.seasar.org/maven/maven2/)
つまり、Fisshplate は Seasar リポジトリから配信されているから注意してね!ということを意味しており、この設定が、repositories の maven の url に追加ということになります。
実践
gradle init --type java-applicationを予め実行- build.gradle のあるディレクトリで実施
- 事前に、
rm -rf ~/.gradleして、ダウンロードした jar ファイルを削除など、Gradle をまっさらにしている。
$ # jcenter() だけだとエラー
$ ./gradlew run
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.seasar.fisshplate:fisshplate:0.1.4.
Searched in the following locations:
- https://jcenter.bintray.com/org/seasar/fisshplate/fisshplate/0.1.4/fisshplate-0.1.4.pom
- https://jcenter.bintray.com/org/seasar/fisshplate/fisshplate/0.1.4/fisshplate-0.1.4.jar
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
1 actionable task: 1 executed
$
$
$
$ # https://www.seasar.org/maven/maven2/ だけだとエラー
$ ./gradlew run
Download https://www.seasar.org/maven/maven2/org/seasar/fisshplate/fisshplate/0.1.4/fisshplate-0.1.4.pom
Download https://www.seasar.org/maven/maven2/ognl/ognl/2.6.9-patch-20090427/ognl-2.6.9-patch-20090427.pom
> Task :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all files for configuration ':compileClasspath'.
> Could not find org.apache.poi:poi:3.2-FINAL.
Searched in the following locations:
- https://www.seasar.org/maven/maven2/org/apache/poi/poi/3.2-FINAL/poi-3.2-FINAL.pom
- https://www.seasar.org/maven/maven2/org/apache/poi/poi/3.2-FINAL/poi-3.2-FINAL.jar
Required by:
project : > org.seasar.fisshplate:fisshplate:0.1.4
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 3s
1 actionable task: 1 executed
$
$
$
$ # jcenter() と https://www.seasar.org/maven/maven2/ の両方あって成功
$ ./gradlew run
Download https://www.seasar.org/maven/maven2/org/seasar/fisshplate/fisshplate/0.1.4/fisshplate-0.1.4.pom
Download https://jcenter.bintray.com/org/apache/poi/poi/3.2-FINAL/poi-3.2-FINAL.pom
Download https://www.seasar.org/maven/maven2/ognl/ognl/2.6.9-patch-20090427/ognl-2.6.9-patch-20090427.pom
Download https://jcenter.bintray.com/log4j/log4j/1.2.13/log4j-1.2.13.pom
Download https://jcenter.bintray.com/commons-logging/commons-logging/1.1/commons-logging-1.1.pom
Download https://www.seasar.org/maven/maven2/org/seasar/fisshplate/fisshplate/0.1.4/fisshplate-0.1.4.jar
Download https://jcenter.bintray.com/commons-logging/commons-logging/1.1/commons-logging-1.1.jar
Download https://www.seasar.org/maven/maven2/ognl/ognl/2.6.9-patch-20090427/ognl-2.6.9-patch-20090427.jar
Download https://jcenter.bintray.com/org/apache/poi/poi/3.2-FINAL/poi-3.2-FINAL.jar
Download https://jcenter.bintray.com/log4j/log4j/1.2.13/log4j-1.2.13.jar
> Task :run
Hello world.
BUILD SUCCESSFUL in 8s
2 actionable tasks: 1 executed, 1 up-to-date
$
おわりに
あまり無いことと思いつつ、現実には必要で、いざやってみようとすると古いゆえに躓きポイントがあったりするものですね。
今回は、その躓きポイントの一つを解決できましたので、ノートいたしました。
最後に、次のページが参考になりました、ありがとうございます!
- javaのビルドをgradleで行う:調査編3:seasar系の依存の注意点 – 文系プログラマによるTIPSブログ
- http://maven.seasar.org/maven2 と URL が古い点に注意
- 第8章 依存関係管理の基本
- Gradle使い方メモ – Qiita
以上です。
