[2.4.6 - Java] SBT multi project build - Sharing common variables and code

291 views
Skip to first unread message

Rajendra Prasad Gujja

unread,
Jan 18, 2016, 8:25:33 PM1/18/16
to play-framework
Hi All,

I am having a lot of troubles in achieving the multi-project (modules) build. The documentation is not so clear.


In the link provided, it is suggested to have a Common.scala in root/project and refer that in sub-project. However, when I try to run the sub-project on its own, it is not able to find the Common which is in root project even after I add the root reference something like bellow

name := "sub-project"

Common.settings

libraryDependencies ++= Common.commonDependencies

lazy val subProject = (project in file("."))
.enablePlugins(PlayJava)
.dependsOn(zeus)

lazy val root = (project in file("../"))

I have also tried to write the Build.scala instead of build.sbt, but no help.

Could somebody please point me to correct documentation? I searched over sbt documentation and internet, all the blogs/articles are talking about defining everything in root/build.sbt but not modularized as suggested in play's link.

Thanks,
Raj.

Barys Ilyushonak

unread,
Jan 21, 2016, 8:47:16 AM1/21/16
to play-framework
Hey Raj,

hopefully you saw it: http://www.scala-sbt.org/0.13/docs/Multi-Project.html

The definitions in .sbt files are not visible in other .sbt files. In order to share code between .sbt files, define one or more Scala files in the project/ directory of the build root.

so in you case the "sub-project" becomes "root" project when you try to start the sbt out of sub dir.

You can run the sbt from correct root project, and then navigate to the sub-project via sbt commands:
projects
project
sub-project



вторник, 19 января 2016 г., 2:25:33 UTC+1 пользователь Rajendra Prasad Gujja написал:

Rajendra Prasad Gujja

unread,
Jan 21, 2016, 1:19:06 PM1/21/16
to play-framework
Hi Barys Ilyushonak,

Thank you very much for clarifying. I am learning sbt and sub-project builds and going through the articles over and over. I now in a little better situation. I was thinking that a sub-project can run on its own without going through "projects" and "project sub-project" but it seems not possible unless I have changed the "devSettings" etc.

Thank you very much for the link, it helped me.

Thanks,
Raj.
Reply all
Reply to author
Forward
0 new messages