2

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!

Community
  • 1
  • 1
ekydfejj
  • 339
  • 2
  • 14
  • Sorry, i'm using sbt.version=0.13.9 – ekydfejj Feb 06 '16 at 22:48
  • Does [this](http://stackoverflow.com/a/33909991/1553233) or [this](https://github.com/imarios/ToySbtMultiProject) help? – marios Feb 06 '16 at 23:48
  • @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 Feb 07 '16 at 16:06

1 Answers1

1

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.

ekydfejj
  • 339
  • 2
  • 14
  • one more word of advice. These docs are perfect, suspect your IDE and try to build locally. No symlink required. – ekydfejj Feb 09 '16 at 02:36