5
3

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.

sbtはpom.xmlに書いてある依存リポジトリを読んでくれない

Last updated at Posted at 2016-03-09

タイトル通り。気づかなかったのでハマった。

sbtは、標準じゃないリポジトリを使う場合、別途書かなければならない

sbtの公式ドキュメントが
http://www.scala-sbt.org/0.13/docs/ja/Library-Dependencies.html

依存ライブラリがデフォルトのリポジトリに存在しないなら、Ivy がそれを見つけられるよう resolver を追加する必要がある。

と謳っているため、導入したいレポジトリのpom.xmlに<repositories>...</repositories>が存在するとき、
そこに書き込まれている依存レポジトリ情報を、手動で build.sbtBuild.scalaに追加してやる必要がある。

実際に遭遇した例

Mavenレポジトリに存在するCSV Validator1を使おうと思い

build.sbt(インポートできない)
libraryDependencies += "uk.gov.nationalarchives" % "csv-validator-core" % "1.1.2"

と書いて $ sbt compile を行ったところ、UNRESOLVED DEPENDENCIESが起きた。

pomファイル2を調べた所、pomファイルに書かれている、読まれるべきレポジトリをsbtが読み込んでいないことに気づいた。以下のようにbuild.sbtに追記したところCSV Validatorをインポートすることが出来た。

build.sbt(依存レポジトリ情報を追加したため、インポートできる)
resolvers += "Scalaz Bintray Repo" at "http://dl.bintray.com/scalaz/releases"
resolvers += "Gilt Group Bintray Repo" at "http://dl.bintray.com/giltgroupe/maven"
libraryDependencies += "uk.gov.nationalarchives" % "csv-validator-java-api" % "1.1.2"
csv-validator-core-1.1.2.pom(依存レポジトリ情報が書かれている)
      :
    <repositories>
        <repository>
            <id>scalaz-bintray</id>
            <name>Scalaz Bintray Repo</name>
            <url>http://dl.bintray.com/scalaz/releases</url>
            <!-- needed for scalaz-stream -->
        </repository>
        <repository>
            <id>gilt-group</id>
            <name>Gilt Group Bintray Repo</name>
            <url>http://dl.bintray.com/giltgroupe/maven</url>
            <!-- needed for gfc-semver -->
        </repository>
    </repositories>
      :
  1. http://mvnrepository.com/artifact/uk.gov.nationalarchives/csv-validator-core/1.1.2

  2. https://jcenter.bintray.com/uk/gov/nationalarchives/csv-validator-core/1.1.2/:csv-validator-core-1.1.2.pom

5
3
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
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?