如何在sbt 1.0.x中发布自定义工件

时间:2018-08-24 15:20:42

标签: sbt debian nexus

我们在build.sbt中有一些自定义代码,以将Debian二进制文件发布到Nexus的sbt 0.13

lazy val distrib = com.typesafe.sbt.packager.Keys.dist

publish := (publish) dependsOn distrib

publishLocal := (publishLocal) dependsOn distrib

artifact in distHack ~= { (art: Artifact) => art.copy(`type` = "deb", extension = "deb") }

val distHack = TaskKey[File]("dist-hack", "Hack to publish dist")

val distHackSettings = Seq[Setting[_]](
  distHack := {
    val packageName = "%s_%s_all" format(normalizedName.value, version.value)
    target.value / (packageName + ".deb")
  }
) ++ Seq(addArtifact(artifact in distHack, distHack).settings: _*)

seq(distHackSettings: _*)

//addArtifact(artifact in distHack, distHack)

publishArtifact in (Compile, packageBin) := false 

publishArtifact in (Compile, packageDoc) := false 

publishArtifact in (Compile, packageSrc) := false

但是,它在sbt 1.x下不起作用。 有人有继续进行的指示吗? 注意:我已经阅读了关于stackoverflow的所有相关问题。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。您使用以下代码

lazy val distrib = com.typesafe.sbt.packager.Keys.dist

artifact in (Compile, packageBin) := {
  val previous: Artifact = (artifact in (Compile, packageBin)).value
  previous.withExtension("deb")
}

publish := (publish dependsOn distrib).value

publishLocal := (publishLocal dependsOn distrib).value

publishArtifact in (Compile, packageBin) := true

publishArtifact in (Compile, packageDoc) := false

publishArtifact in (Compile, packageSrc) := false

publishArtifact in Test := false