Play! 2.1 sbt publish a dist cycle in tasks error

守給你的承諾、 提交于 2020-01-16 02:52:07

问题


Upon migrating from 2.04 to 2.1, we encountered a problem with our publish task that sends the zip file from the dist task to Artifactory.

Now what we are getting is the folowing error:

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

There is discussion about this in the play framework user groups:

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

and

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

We basically tried to do what they recommend but we are getting nowhere. Could someone please give us an example of what the Build.scala should look like?

What we have is the following:

  /*
    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:


The problem was that the dist task and publish task where in a cycle. So all we had to do is have the publish task depend on distHack. In other words, we replaced this:

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

with

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

There was also another problem. The main app.jar was not being included in the dist. So we had to comment the line that prevented from publishing the packaged binary in 2.0.4:

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


来源:https://stackoverflow.com/questions/17473088/play-2-1-sbt-publish-a-dist-cycle-in-tasks-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!