1
votes

I'm following up on this question, as it helped me get my "common" project recognized, but i'm not able to use it. How to reference external sbt project from another sbt project?

Project structure

/src/services/api/project

  • build.sbt contains all dependencies, plus dependsOn(commonlib)

/src/commonlib/project

  • build.sbt is very minimal, just basic definitions.

SBT loads everything fine, when i click on the object i'm trying to use it opens in intellij and import commonlib.conversions.SomeConversion is recognized (by Intellij and clickable to my local copy).

api - sbt

lay val project = Project( id = "company", file("."), settings)
.enablePlugins(JettyPlugin)
.dependsOn(commonlib)

lazy val commonlib = RootProject(file("../../commonlib"))

commonlib is also an SBT project with /src/commonlib/src/main/scala/commonlib

in the main project i'm importing

import commonlib.conversions.SomeConversion
...
val converted = SomeConversion.convert(x)

I get a comple error stating: not found: object commonlib

The top of the commonlib.conversions looks like

package commonlib.conversions

Any help is greatly appreciated. I may be headed down the wrong path entirely and could likely solve this with git subrepos, but i'm looking to share this across multiple projects hence the (slightly) made up name. And ultimately understand the import/sbt system better. I don't want this to be a remote jar as i'll be editing as much as the api package.

Thanks!

1
Sorry, i'm using sbt.version=0.13.9ekydfejj
Does this or this help?marios
@marios - that helped, thank you, i was actually looking at the first page, but getting something wrong. I ended up with just the two projects "api" and "companylib". Both have their own build.sbt files and it seems like i had to symlink /src/companylib inside of /src/company/api. Then my Project definition inside api/build.sbt looked like lazy val coreLib = RootProject(file("../../companylib")) and made the api project.dependsOn(coreLib). So far so good, but still working out a few kinks. Thanks for the pointers. I'm too new to publicly upvote your url, i'll be sure to come back.ekydfejj

1 Answers

1
votes

Taking advice from @marios i used the sbt docs, which i was working off, but his advice and github link forced me to dig a bit further.

Ultimately the commonlib project is defined inside of the api project like:

lazy val coreLib = RootProject(file("../../commonlib"))

And at the end of the api project definition in its build.sbt i have attached

.dependsOn(coreLib)

Which is nearly what i had above and tweak or two, plus cleaning my Intellij cache very likely helped.