1

I cloned a repository from GitHub to my local machine, changed it to fit my needs and now I'm going to use it in my project. I guess I must use .jar file from it. However, there is no such a file.

Do I have to generate it myself?

Also, how do I refer to it? I don't want to copy it to /lib folder for now because I keep working on the cloned project. As I found out I have to use this:

resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository" 

However, I don't have the file build.sbt, I only have file a plain scala file titled Build.scala and it's not possible to use code above in it.

Also, it says /.m2/repository, but how does it know where .jar file is in this repository?

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • 2
    SBT uses a local ivy cache repository and follows a maven based project structure. Look in `~/.ivy2/cache` for built jars. You may also want to look at [fetching dependencies from git](http://stackoverflow.com/q/7550376/205936) – S.R.I Nov 22 '13 at 04:38
  • Duplicate of http://stackoverflow.com/q/20083564/1305344 and http://stackoverflow.com/q/7550376/1305344 – Jacek Laskowski Dec 28 '13 at 20:25
  • @JacekLaskowski, it is not because those question are not about a local dependency. –  Dec 29 '13 at 03:08

1 Answers1

4

Since the project comes from GitHub I assume it's a git project. The solution is to use RootProject with git URI as a reference to your cloned git project.

Say you cloned the project to /Users/jacek/sandbox/so/sbt-git/git-repo (as I did in Can SBT refresh git uri dependency (always or on demand)?).

Do git log to find out the last commit you want to reference and use it in the git URI of the referenced project in SBT - in dependsOn.

Given the last commit is a221379c7f82e5cc089cbf9347d473ef58255bb2, build.sbt could look as follows:

lazy val v = "a221379c7f82e5cc089cbf9347d473ef58255bb2"

lazy val g = RootProject(uri(s"git:file:///Users/jacek/sandbox/so/sbt-git/git-repo/#$v"))

lazy val root = project in file(".") dependsOn g

It's also possible to leave out the commit id and keep up with the development in the referenced git project after it's updated with git fetch followed by git merge as described in git-pull(1) Manual Page.

Community
  • 1
  • 1
Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • I applied your solution, it compiles but I finally get a ClassNotFoundException. Any idea why? – pommedeterresautee Jun 10 '14 at 20:23
  • What kind of project is this - maven, gradle, sbt? Does the project follow standard directory structure of Maven/sbt? As a matter of fact, even with a proper setup of the projects you may face CNFE due to a bug in the project(s). Would you mind sharing the project via github? – Jacek Laskowski Jun 11 '14 at 09:34