There are several ways how you can use your project in another project. I will not discus the publishing to remote repository, as that's probably something you don't want to do anyway (at least at this point in time).
Lets assume you have a project called projectA - the build.sbt
is just this:
name := "project-a"
organization := "com.acme"
version := "0.1.0"
And you have another project called projectB, where you want to use classes defined in projectA.
Unmanaged Dependency
One of the simplest ways is to use it as a unmanaged dependency. You can do that by putting the jar
file produced by package
, assembly
or any other command producing an artefact.
Local Repository
Another way to use your dependency is to publish it to your local repository. Given the projectA as defined above, to the build.sbt
of a projectB, add a dependency
libraryDependencies += "com.acme" %% "project-a" % "0.1.0"
Now you can publish projectA to your local repository by executing publishLocal
in the projectA. The advantage of this approach is that if your projectA declares any dependencies, they will be added as transitive dependencies to projectB.
Project Dependency
Last way that comes to my mind is to declare dependency directly on the projectA. You can do that by creating a build.sbt
file in the projectB, which looks more or less like this
lazy val projectA = file("/home/lpiepiora/q-23607291/projectA")
lazy val projectB = project in file(".") dependsOn projectA
Now classes declared in projectA should be visible in projectB.