执行 sbt clean assembly 时 sbt clean assembly 出错

Error on sbt clean assembly when doing sbt clean assembly

在 sbt shell 我得到

sbt clean assembly
[error] Expected ';'
[error] sbt clean assembly
[error]                   ^

^ 代表什么?如何定义预期的地方 ;?

我们的build.sbt

import Settings.{assemblySettings, baseImageDockerSettings, commonSettings, finalDockerSettings, environmentArtifactSettings}
import com.typesafe.sbt.SbtGit.GitKeys.gitCurrentBranch
import sbt.{Def, project}
import complete.DefaultParsers._
import sbt.complete._
import sbtrelease.ReleaseStateTransformations.{inquireVersions, setReleaseVersion}
import sbtrelease.{Version, versionFormatError}

version := sparkAppsIndustryVersionSetting.value

lazy val sparkAppsIndustryVersionSetting = Def.setting{
    s"${if (releaseUseGlobalVersion.value) (version in ThisBuild).value else version.value}"
}

releaseVersion := {
    ver => Version(ver).map(_.bump(releaseVersionBump.value).withoutQualifier.string).getOrElse(versionFormatError(ver))
}

releaseProcess := Seq[ReleaseStep](
    inquireVersions,
    setReleaseVersion
)

val minor: Parser[String] = " minor"
val major : Parser[String] = " major"
val combinedParser: Parser[String] = minor | major

//sbt 'bumpVersion minor'
val bumpVersion = inputKey[Unit]("Bumps a version of the bigdata project.")
bumpVersion := {
    val bumpMode = combinedParser.parsed.trim match {
        case "minor" => sbtrelease.Version.Bump.Minor
        case "major" => sbtrelease.Version.Bump.Major
    }
    require(gitCurrentBranch.value.contains("stage") || gitCurrentBranch.value.contains("master"),
        "A version can bumped in the 'master' or 'stage' branches only.")
    val extracted = Project.extract(state.value)
    val newState = extracted.appendWithSession(Seq(releaseVersionBump := bumpMode), state.value)
    Command.process("release with-defaults", newState)
}

//Prints current bigdata project version (sbt printVersion | tail -n 2 | head -1)
lazy val printVersion = taskKey[Unit]("Prints current project version.")
printVersion := println(sparkAppsIndustryVersionSetting.value)


lazy val industry = (project in file("."))
  .enablePlugins(sbtdocker.DockerPlugin)
  .enablePlugins(AshScriptPlugin)
  //  .enablePlugins(HelmPlugin)
  .settings(
    name := "industry",
    commonSettings,
    assemblySettings,
    environmentArtifactSettings,
    libraryDependencies ++= Seq(
      "companyname" %% "deps" % "0.1",
      "companyname" %% "core" % "0.1"
    ),
    baseImageDockerSettings,
    finalDockerSettings("core", "0.1"),
    Compile / mainClass := Some("io.companyname.industry.batch.DailySummariesJob"),
    addArtifact(Compile / assembly / artifact, assembly)
  )

我们的plugins.sbt

// Deploy fat JARs. Restart processes: https://github.com/sbt/sbt-assembly
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")

// sbt plugin for dockerization: https://github.com/sbt/sbt-native-packager
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.24")

// sbt plugin to build Docker Images: https://github.com/marcuslonnberg/sbt-docker
addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.8.2")

// sbt plugin for release management
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.12")

// sbt plugin for git routines
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")

// sbt plugin for publishing jars to gitlab
addSbtPlugin("com.gilcloud" % "sbt-gitlab" % "0.0.6")

如果我根据 Jarrod Baker 的建议在 sbt shell 中只执行 clean assembly,我可以很好地执行命令,但最后我仍然遇到错误:

[info] Loading global plugins from C:\Users\eljah32\.sbt.0\plugins
[info] Loading settings for project industry-dev-build from plugins.sbt,idea8.sbt ...
[info] Loading project definition from D:\Java\companyname\industry-dev\project
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] Compiling 5 Scala sources to D:\Java\companyname\industry-dev\project\target\scala-2.12\sbt-1.0\classes ...
[info] Done compiling.
[info] Loading settings for project industry from build.sbt ...
[info] Set current project to industry (in build file:/D:/Java/companyname/industry-dev/)
[info] Defining Global / ideaPort
[info] The new value will be used by Compile / compile, Test / compile
[info] Reapplying settings...
[info] Set current project to industry (in build file:/D:/Java/companyname/industry-dev/)
[IJ]sbt:industry> clean assembly
[error] Expected ';'
[error] clean assembly
[error]               ^
[IJ]sbt:industry>

当您使用 SBT shell 时,您无需在命令前键入 sbt。如果您在命令行上使用 sbt clean assembly,在 shell clean assembly 中就足够了。