如何在sbt 1.0.x中发布自定义工件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在sbt 1.0.x中发布自定义工件相关的知识,希望对你有一定的参考价值。
我们在build.sbt中有一些自定义代码,可以将debian二进制文件发布到nexus for 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的所有相关问题。
答案
我找到了解决方案。您使用以下代码
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
以上是关于如何在sbt 1.0.x中发布自定义工件的主要内容,如果未能解决你的问题,请参考以下文章