LoginSignup
38
34

More than 5 years have passed since last update.

Github 上のライブラリや sbt plugin を使う (sbt 0.13 以降用)

Posted at

Scala のライブラリや sbt plugin のうち、maven central などのレポジトリに登録されていないものを使うのも sbt なら簡単です。
自分で fork してちょっと書き換えたバージョンを使いたい場合なんかにも使えます。

Github 上のライブラリを使う

user/repo-name を使いたいと仮定して build.sbt に次のように書きます。

build.sbt
lazy val root = project.in(file(".")).dependsOn(githubRepo)

lazy val githubRepo = uri("git://github.com/user/repo-name.git#commit")

いくつか注意点があります。

  • 1行目と3行目の間に空行(改行だけの行)が必要です。
  • uri() 引き数のフォーマットに注意します。Github の SSH clone URL では通りません。たとえば nscala-time の場合、SSH clone URL は git@github.com:nscala-time/nscala-time.git ですが、git://github.com/nscala-time/nscala-time.git を指定します(@://:/ の二箇所、よく見てください)。
  • uri には #commit で branch 名や commit id を指定できます。特定の commit を使い続けたい場合に指定します。

なお、「Github上」と書きましたが、公開 Git レポジトリであれば Github である必要はありません。Bitbucket でも Gitlab でも Gitbucket でもいいです。

Github 上の sbt plugin を使う

sbt plugin の場合も書き込むファイルが違うだけで、あとは同じです。
user/repo-name が sbt plugin だとして、project/plugins.sbt に次のように書きます。

project/plugins.sbt
lazy val root = project.in(file(".")).dependsOn(githubRepo)

lazy val githubRepo = uri("git://github.com/user/repo-name.git#commit")

注意点はライブラリの場合と同じです。

38
34
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
38
34