我正在使用前面提到的 sbt 插件来获取我正在开发的应用程序的版本。
该项目有子模块。这里是主要的build.sbt
...
lazy val abandon = (project in file(".")).
aggregate(base, cli, gui).
dependsOn(base, cli, gui).
enablePlugins(BuildInfoPlugin).
settings(commonSettings: _*).
settings(
name := "abandon",
fork in run := true,
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion),
buildInfoPackage := "co.uproot.abandon"
)
lazy val base = (project in file("base")).
settings(commonSettings: _*).
settings(
name := "abandon-base",
fork in run := true
)
lazy val cli = (project in file("cli")).
dependsOn(base).
settings(commonSettings: _*).
settings(
name := "abandon-cli",
fork in run := true
)
lazy val gui = (project in file("gui")).
dependsOn(base).
settings(commonSettings: _*).
settings(
name := "abandon-gui",
fork in run := true
)
生成BuildInfo.scala
的位于target/scala-2.11/src_managed/main/sbt-buildinfo/BuildInfo.scala
预期的下方。
package co.uproot.abandon
import scala.Predef._
/** This object was generated by sbt-buildinfo. */
case object BuildInfo {
/** The value is "abandon". */
val name: String = "abandon"
/** The value is "0.3.1". */
val version: String = "0.3.1"
/** The value is "2.11.8". */
val scalaVersion: String = "2.11.8"
/** The value is "0.13.12". */
val sbtVersion: String = "0.13.12"
override val toString: String = {
"name: %s, version: %s, scalaVersion: %s, sbtVersion: %s" format (
name, version, scalaVersion, sbtVersion
)
}
}
当我转到里面的文件package co.uproot.abandon
并尝试引用时,BuildInfo.version
我得到
Error:(256, 42) object BuildInfo is not a member of package co.uproot.abandon
co.uproot.abandon.BuildInfo.version
我在这里阅读了有关子模块和此插件的问题,并最终尝试了此解决方法,但这没有帮助。
任何帮助将不胜感激!