maven-enforcer-plugin を使用して、依存関係の収束の問題を確認します。典型的な出力は次のようになります。
[WARNING] Rule 1: org.apache.maven.plugins.enforcer.DependencyConvergence failed
with message:
Failed while enforcing releasability the error(s) are [
Dependency convergence error for junit:junit:3.8.1 paths to dependency are:
+-foo:bar:1.0-SNAPSHOT
+-ca.juliusdavies:not-yet-commons-ssl:0.3.9
+-commons-httpclient:commons-httpclient:3.0
+-junit:junit:3.8.1
and
+-foo:bar:1.0-SNAPSHOT
+-junit:junit:4.11
]
このメッセージを見て、私は通常、推移的な依存関係を除外することで「解決」します。
<dependency>
<groupId>ca.juliusdavies</groupId>
<artifactId>not-yet-commons-ssl</artifactId>
<version>0.3.9</version>
<exclusions>
<!-- This artifact links to another artifact which stupidly includes
junit in compile scope -->
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
これが本当に修正であるかどうか、およびこの方法でライブラリを除外することに伴うリスクを理解したいと思います。私の考えでは:
新しいバージョンを使用することを選択している場合、「修正」は通常安全です。これは、下位互換性を維持しているライブラリ作成者に依存しています。
通常、Maven ビルドへの影響はありません (より近い定義が優先されるため) が、依存関係を除外することで、この問題について知っていることを Maven に伝え、maven-enforcer-plugin を緩和します。
私の考えは正しいですか?この問題を処理する別の方法はありますか? 一般的なケースに焦点を当てた回答に興味があります-junit
上記の例は少し奇妙です。