1

Given a simple project structure like this:

+ lib1/
|   + build.sbt
+ build.sbt

where

./lib1/build.sbt is:

name := "Library 1"

./build.sbt is:

lazy val lib1 = 
  project.in(file("lib1")).settings(name := "Blah blah", version := "1.2.3")

What seems to happen is that settings in ./lib1/build.sbt override settings for the same project specified in build.sbt because lib1/name resolves to "Library 1" and not "Blah blah" but lib1/version resolves to "1.2.3" from the sbt console.

Is there any way I could make it the other way around, so that I can override some settings specified in ./lib1/build.sbt in ./build.sbt instead?

Edit:

Similarly, if ./lib1/build.sbt is just a plain list of settings as above I can do this in the main build.sbt:

lazy val lib1 = project.in(file("lib1"))
lazy val lib2 = project.in(file("lib2")).dependsOn(lib1)

and I can see that it works by checking show lib2/internalDependencyClasspath in console, however if ./lib1/build.sbt is instead

lazy val lib1 = project.in(file(".")).settings(name := "Library 1")

I can no longer use dependsOn in the main build.sbt

Related:

SBT: Override setting in multi-build dependsOn/aggregate project

Ivan Poliakov
  • 2,245
  • 1
  • 18
  • 19
  • I think it's not possible to change this order. I won't give you any proofs, but I think it's considered bad practice nowadays to use multiple `build.sbt`s in subprojects. You can define all your subprojects, their settings and inter-dependencies in the root `build.sbt`. – laughedelic Dec 06 '17 at 14:05
  • But what if I want the subproject to be a standalone buildable/publishable library? – Ivan Poliakov Dec 06 '17 at 14:21
  • Then just make it an independent sbt project, why do you want to _redefine_ it in a multi-project build? You can probably still create a "meta-project" which will aggregate several such independent libraries via source dependencies. – laughedelic Dec 06 '17 at 15:15
  • For instance the library has a jar dependency on another library (for the standalone build) that I want to replace with a source dependency for the multi-project build. – Ivan Poliakov Dec 06 '17 at 21:11
  • I see now. Unfortunately, I don't know how to solve it. – laughedelic Dec 07 '17 at 15:17

0 Answers0