1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[playframework2][sbt]ライブラリの互換性警告対応 There may be incompatibilities among your library dependencies

1
Last updated at Posted at 2019-11-28

背景・問題点

playを2.6にバージョンアップしたところ、sbt update時に以下の警告が発生するようになりました。
直訳すると「ライブラリの依存関係に互換性がない可能性があります。追い出されたライブラリの一部を次に示します。」

競合されたライブラリと矢印の右側に採用されたバージョンが表示されています。
動作は問題ないのですが目障りなので消したい。という話

[warn] There may be incompatibilities among your library dependencies.
[warn] Here are some of the libraries that were evicted:
[warn] 	* com.typesafe.play:play-java-jdbc_2.11:2.5.0 -> 2.6.0
[warn] 	* com.typesafe.play:twirl-api_2.11:1.1.1 -> 1.3.2
[warn] Run 'evicted' to see detailed eviction warnings

原因(の調査方法)

警告メッセージの末尾に記載されているように、evictedで詳細を確認できます。

$ sbt evicted | grep jdbc

以下のような出力が得られました。play-jdbcが2.6.0、play-jdbc-evolutionsが2.5.0を使っているようです。

[warn] 	* com.typesafe.play:play-jdbc-api_2.11:2.5.0 -> 2.6.0 \
(caller: com.typesafe.play:play-jdbc_2.11:2.6.0, com.typesafe.play:play-jdbc-evolutions_2.11:2.5.0)

対策・手順

理想的にはevictedコマンドを使ったり、各ライブラリのリポジトリや文書を調査して、互換性を維持できるように各ライブラリを選択してバージョンを明示的に指定することです。が!それを調べるのも、整合性を維持するのも現実的には難しいと思います。

そこで、選択されたバージョンに固定することで対応します。(もちろん、この警告が出ていても正常動作していることが前提です)

具体的にはbuild.sbtに以下の行を追加します。

build.sbt
dependencyOverrides += "com.typesafe.play" %% "play-java-jdbc" % "2.6.0"

ここではjdbcしか指定していませんが、これを指定するだけでtwirlの警告も消えました。

dependencyOverrides については公式ドキュメントの説明がわかりやすいです。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?