git变量是哪种轴?

时间:2019-05-28 18:47:51

标签: scala sbt

我的build.sbt文件如下所示:

//Git settings
git.useGitDescribe := true
git.formattedShaVersion := git.gitHeadCommit.value map { _ =>
  git.gitCurrentTags.value.head
}

Docker / dockerAlias := DockerAlias(None, Some("zerocoder"), (packageName in Docker).value, git.gitDescribedVersion.value)

lazy val root = (project in file("."))
  .enablePlugins(DockerPlugin, JavaServerAppPackaging, GitVersioning)
  .settings(
    name := "plugger",
    libraryDependencies ++= Seq(
      "org.typelevel" %% "cats-core" % "1.6.0",
      "ch.qos.logback" % "logback-classic" % "1.2.3",
      "com.typesafe.scala-logging" %% "scala-logging" % "3.9.2",
      "com.typesafe.akka" %% "akka-slf4j" % "2.5.22",
      "io.circe" %% "circe-core" % "0.11.1",
      "io.circe" %% "circe-generic" % "0.11.1",
      "io.circe" %% "circe-parser" % "0.11.1",
      "org.scala-lang" % "scala-library" % "2.12.8",
      "com.typesafe.akka" %% "akka-actor" % "2.5.22",
      "com.typesafe.akka" %% "akka-stream" % "2.5.22",
      "com.typesafe.akka" %% "akka-http" % "10.1.8",
      "com.typesafe.akka" %% "akka-stream-kafka" % "1.0.1",
      "org.scalacheck" %% "scalacheck" % "1.14.0" % "test",
      "org.scalactic" %% "scalactic" % "3.0.6" % "test",
      "org.scalatest" %% "scalatest" % "3.0.6" % "test",
      "com.dimafeng" %% "testcontainers-scala" % "0.25.0" % "test"
    ),
    addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.3"),
    scalacOptions ++= Seq(
      "-encoding", "UTF-8", // source files are in UTF-8
      "-deprecation", // warn about use of deprecated APIs
      "-unchecked", // warn about unchecked type parameters
      "-feature", // warn about misused language features
      "-language:higherKinds", // allow higher kinded types without `import scala.language.higherKinds`
      "-Xlint", // enable handy linter warnings
      "-Xfatal-warnings", // turn compiler warnings into errors
      "-Ypartial-unification" // allow the compiler to unify type constructors of different arities
    ),
    scalacOptions in(Compile, console) ~= {
      _.filterNot(Set("-Xlint"))
    }

  )

如您所见,我正在使用GitVersioning插件,git变量是哪种轴作用域?

Docker是作用域,而dockerAlias是作用域,因为我可以编写Docker / dockerAlias

我也尝试写git / useGitDescribe,但是不起作用。

1 个答案:

答案 0 :(得分:1)

git不在sbt的任何作用域轴中。它只是一个拥有键的对象:https://github.com/sbt/sbt-git/blob/v1.0.0/src/main/scala/com/typesafe/sbt/SbtGit.scala#L212

如您所见,它还会重新定义ThisBuild参考范围轴中的大多数键。我只见过sbt-git这样做,但是效果是,如果您在项目设置(即git.baseVersion中使用.settings(..),那么它将在构建级别而不是项目中保持定义级。