玩! 2.1 sbt在任务错误中发布dist循环

时间:2013-07-04 14:42:15

标签: scala playframework-2.0 sbt artifactory

从2.04迁移到2.1时,我们遇到了一个问题,我们的发布任务将zip文件从dist任务发送到Artifactory。

现在我们得到的是以下错误:

Internal task engine error: nothing running.  This usually indicates a cycle in tasks.

在play框架用户组中有关于此的讨论:

  

https://github.com/playframework/Play20/pull/535

  

https://groups.google.com/forum/#!topic/play-framework/BoWw65F6vg8

我们基本上试图按照他们的建议行事,但我们无处可去。有人可以给我们一个Build.scala应该是什么样子的例子吗?

我们拥有以下内容:

  /*
    In order to solve the cycle generated during the dist task in play 2.1
  */
  val distHack = TaskKey[File]("dist-hack", "Hack to publish dist")

  val myDistSettings = Seq[Setting[_]] (
      publish <<= (publish) dependsOn play.Project.dist,
      publishLocal <<= (publishLocal) dependsOn play.Project.dist,
      artifact in distHack ~= { (art: Artifact) =>
        art.copy(`type` = "zip", extension = "zip")
      },
      distHack <<= (distDirectory, version) map { (d, v) =>
        val packageName = "%s-%s" format(appName, v)
        println(packageName)
        val zip = d / (packageName + ".zip")
        zip
      }
    ) ++ Seq(addArtifact(artifact in distHack, distHack).settings: _*)

    lazy val main = play.Project(appName, appVersion, appDependencies)
        ...
    .settings(addArtifact(Artifact(appName, "zip","zip"), dist).settings : _*)
            ...
    .settings(
        // disable publishing the main jar produced by `package`
        publishArtifact in (Compile, packageBin) := false,

        // disable publishing the main API jar
        publishArtifact in (Compile, packageDoc) := true,

        // disable publishing the main sources jar
        publishArtifact in (Compile, packageSrc) := false,
        publishArtifact in Test := false,
        crossPaths := false, 
        publishTo := Some("Artifactory Realm" at "somewhere"),
        credentials += Credentials(".credentials"),
        scalacOptions ++= Seq("-feature")
    )
    .settings(myDistSettings: _*)

1 个答案:

答案 0 :(得分:2)

问题在于dist任务和发布任务在一个循环中。所以我们所要做的就是让发布任务依赖于 distHack 。换句话说,我们取而代之:

.settings(addArtifact(Artifact(appName, "zip","zip"), dist).settings : _*)

.settings(addArtifact(Artifact(appName, "zip","zip"), distHack).settings : _*)

还有另一个问题。主app.jar没有包含在dist中。因此,我们必须评论阻止在2.0.4中发布打包二进制文件的行:

//publishArtifact in (Compile, packageBin) := false,