2

Is it possible to write a build.sbt for Play 2.2+ that dependsOn a GitHub project? The dependency is a library, not a Play module, and it is a private BitBucket repo so it needs authentication. The resulting project is pushed up to Heroku for deployment.

How can sbt pull dependency artifacts from git? doesn't show the build.sbt syntax and doesn't address the authentication issue.

Community
  • 1
  • 1
Mike Slinn
  • 7,705
  • 5
  • 51
  • 85

1 Answers1

2

It's quite legitimate and the answer is as simple as the following in build.sbt:

lazy val bananaRdfProject =
  ProjectRef(uri("https://github.com/w3c/banana-rdf.git"), "banana-rdf")

and then dependsOn the lazy val, or

lazy val core = project dependsOn(
  ProjectRef(uri("git://github.com/w3c/banana-rdf.git"), "banana-jena")
)

See Can multi-projects from GIT be used as SBT dependencies? and SBT dependsOn RootProject: doesn't compile the dependency.

Community
  • 1
  • 1
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • How would authentication be specified for a private BitBucket project? – Mike Slinn Feb 01 '14 at 18:05
  • I didn't try it out, but **if** there's a hg URL that accepts username and password, that would do the trick. Since SBT uses `hg` command line tool, the tool can handle it with a special configuration - see [How to save username and password with Mercurial?](http://stackoverflow.com/a/2589195/1305344). – Jacek Laskowski Feb 01 '14 at 23:53
  • My question is about git. – Mike Slinn Feb 02 '14 at 06:37
  • I think the combination of `git clone` (authentication) and `RootProject` (referencing the cloned project) might be a good fit to your use case. – Jacek Laskowski Feb 02 '14 at 13:50
  • Sounds nice. How exactly would that work for Heroku? – Mike Slinn Feb 02 '14 at 17:29
  • I would expect Heroku scripts to allow to perform actions, e.g. `git clone` before others. I don't know the details, though. – Jacek Laskowski Feb 03 '14 at 09:45
  • Heroku is driven from git push. https://devcenter.heroku.com/articles/git#deploying-code – Mike Slinn Feb 03 '14 at 14:25
  • That's correct, but you can write scripts as part of a build/deployment process. – Jacek Laskowski Feb 03 '14 at 15:22
  • Of course. The question is how to supply authentication information – Mike Slinn Feb 03 '14 at 19:24
  • 5
    I tried this in my build.sbt file, and I see SBT cloning the dependency, placing it in ~/.sbt and even in IntellJ, it shows up now as a module, but I still can't import any class files from that module, either in IntellJ or if I give sbt a compile command – djsumdog Feb 27 '14 at 21:08