SBT自定义任务挂起

时间:2014-03-26 06:20:11

标签: scala jar sbt onejar sbt-onejar

我的taskKey中有以下自定义built.sbt

(这是我第一次尝试定义自定义SBT任务,所以要小心愚蠢)

lazy val makeDeployJar = taskKey[java.io.File](
  "Runs 'package', collects all the sub-project JARs in the lib folder of the root project, and runs 'one-jar'")

makeDeployJar := {
  val jars = List(
    (Keys.`package` in Compile in root).value,
    (Keys.`package` in Compile in common).value
    (Keys.`package` in Compile in core).value,
    (Keys.`package` in Compile in analysisProj).value,
    (Keys.`package` in Compile in ui).value
  )
  // looks like OneJar operates on JARs in the lib folder only, so need to collect all JARs
  // and temporarily copy them to lib and delete them later:
  val libDir = (baseDirectory in root).value / "lib"
  val libPaths = jars.map(libDir / _.getName)
  IO.copy(jars zip libPaths)
  val oneJarOutput = oneJar.value
  IO.delete(libPaths)
  // move the resulting JAR to a more human friendly location
  val finalPath = (baseDirectory in root).value / "profile.jar"
  IO.copyFile(oneJarOutput, finalPath)
  // this is the tedious SBT way of logging
  streams.value.log.info(finalPath.toString)
  // return the resulting JAR path for completeness' sake
  finalPath
}

尽管它很复杂但它运行良好并产生了我追求的结果。

但是,当我将以下内容添加到built.sbt

artifactName in ThisBuild := {
  (_: ScalaVersion, module: ModuleID, artifact: Artifact) =>
  artifact.name + "-" + module.revision + "." + artifact.extension
}

每当我运行makeDeployJar任务时,它会在输出后无限期挂起:

...
[info] Compiling 16 Scala sources and 3 Java sources to /myproj/ui/target/scala-2.10/classes...
[info] Packaging /myproj/target/scala-2.10/myproj-0.1-SNAPSHOT.jar ...
[info] Done packaging.
[info] Packaging /myproj/target/scala-2.10/myproj-0.1-SNAPSHOT.jar ...
SBT是一个复杂的野兽,我是SBT的新手 - 我做错了什么,或者这是SBT中的一个错误?

0 个答案:

没有答案