2015年7月9日、突如としてmavenを利用してビルドが出来なくなった。
何が起きたのか。
こんなエラーが出てしまう。
[ERROR] Failed to execute goal on project hoge: Could not resolve dependencies for project hoge:jar:1.0.0: Failed to collect dependencies at jasperreports:jasperr eports:jar:2.0.2 -> com.lowagie:itext:jar:4.2.2: Failed to read artifact descriptor for com.lowagie: itext:jar:4.2.2: Could not transfer artifact com.itextpdf:itextpdf:pom:4.2.2 from/to jaspersoft (htt p://www.jasperforge.org/maven2): Access denied to: http://www.jasperforge.org/maven2/com/itextpdf/it extpdf/4.2.2/itextpdf-4.2.2.pom , ReasonPhrase:Forbidden. -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following arti cles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
原因はなにか。
どうやら、
jasperreports:jasperreports:jar:2.0.2 -> com.lowagie:itext:jar:4.2.2
ここに問題があるらしい。
jasperreports 2.0.2のpom.xmlを覗くと、
<dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>[1.02b,)</version> <scope>compile</scope> </dependency>
の記載通り、1.02b以上の最新バージョンを取得しようとしている。
7月9日時点のcom.lowagie:itextの最新バージョンは
こちらで確認する限り4.2.2らしく、エラーメッセージ通り4.2.2を持ってこようとしている。
で、mavenのセントラルリポジトリ内には、4.2.2に対応するjarは無く、あろうことか
<distributionManagement> <relocation> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>4.4.2</version> <message> After release 2.1.7, iText moved from the MPLicense to the AGPLicense. The groupId changed from com.lowagie to com.itextpdf and the artifactId from itext to itextpdf. See http://itextpdf.com/functionalitycomparison for more information. </message> </relocation> </distributionManagement>
でrelocateしてくれちゃっている。
relocate先には対応するバージョンがなく、結果としてitext4.2.2の取得に失敗してしまっている。
※現在はrelocate先のバージョンは5.5.6になっています。なっていますが、商用利用はできないでしょう。。。
どうすればよいのか。
maven - Dependency error in jasper-reports from itext - Stack Overflowでも議論されているが、
jasperreportsのバージョンを3.0.1まで上げるか、jasperreportsのpom.xmlをいじるしか回避策はないかと思います...
一種のテロかと。