Current situation
My project setup looks somewhat like this:
Project: root (build.sbt
, version.sbt
)
Sub-project: projectA (build.sbt
)
Sub-project: projectB (build.sbt
)
In my version.sbt
I have a val
that reads the version to use from an external json file like this:
version in ThisBuild := findVersion
lazy val findVersion: String =
parse(Source.fromFile("../buildProperties.json").mkString).map(_ \\ "version").map(_ map (_.asString)) match {
case Right(Some(x) :: _) => x
case _ => throw new IllegalArgumentException("Unable to read buildProperties.json")
}
The problem
I now need to use this version to define dependencies inside the subprojects (projectA & projectB). So I either:
- need to access the
val findVersion
of the root project from within thebuild.sbt
of projectA & projectB OR - need to use the version directly like this in the build.sbt of projectA & projectB:
libraryDependencies += "ext-lib" % "com.fbaierl" % version.value % Provided
. But this results in aerror: 'value' can only be used within a task or setting macro, such as :=, +=, ++=, Def.task, or Def.setting.
exception.
Is there any way I can achieve what I need?