Referring to parameter in root sbt project from subproject

How can I reference a baseDirectoryroot project from within subprojects in a multi-project sbt assembly? how

lazy val full: Project = Project(
  id = "full",
  base = file("."),
  ..
)

lazy val sub = Project(
  id = "sub",
  base = file("sub"),
  ..
  settings = Seq(
    javaSource in Compile := full.settings.baseDirectory / "foo" / "src"
  )
)

This attempt just gives me:

: error: ambiguous reference to overloaded definition,
both method settings in trait Project of type (ss: sbt.Def.Setting[_]*)sbt.Project
and  method settings in trait ProjectDefinition of type => Seq[sbt.Def.Setting[_]]
match expected type ?
    javaSource in Compile := full.settings.baseDirectory / "foo" / "src",
                                  ^
+4
source share
1 answer

In sbt, projects are another installation axis (along with configurations and tasks). Thus, you can use the operator into access the parameter value in another project. To get the value of the installation key baseDirectoryin the project full, you should write

(baseDirectory in full).value

Therefore, your full parameter javaSourceshould be:

javaSource in Compile := (baseDirectory in full).value / "foo" / "src"

See the Area documentation in sbt for the entire story.

( , settings Project , . , .)

+4

Source: https://habr.com/ru/post/1546422/


All Articles