[英]Publish zip created by sbt-native-packager
我正在尝试将sbt-native-packager插件通过Universal:packageBin任务生成的 zip 文件发布到存储库。
我这样配置我的项目:
publishTo := Some("Repo" at "http://repo")
publishMavenStyle := true
packagerSettings
packageArchetype.java_application
我正在努力尝试使用发布任务和 packageBin 任务来创建一个新的 sbt 任务(名为 publishZip)来发布 zip 文件。 我怎样才能做到这一点?
将以下行添加到您的 sbt 构建中(在 packagerSettings 周围应该没问题)
deploymentSettings
根据您想要执行的操作,您可能不需要定义可以运行的 publishZip 任务
sbt universal:publish
应该只发布 zippublish <<= publish.dependsOn(publish in config("universal"))
然后运行 sbt 发布。
为了完整起见, deploymentSettings
(和packagerSettings
)来自com.typesafe.sbt.SbtNativePackager
这对于了解您是否使用 scala 构建很有用:)
deploymentSettings
有效,但我想优化设置。 似乎有几个问题正在发生。 我终于想出了以下解决方案:
//--use sbt-native-packager default java application
packageArchetype.java_application
//--a dummy task to hold the result of the universal:packageBin to stop the circular dependency issue
val packageZip = taskKey[File]("package-zip")
//--hard coded result of "universal:packageBin"
packageZip := (baseDirectory in Compile).value / "target" / "universal" / (name.value + "-" + version.value + ".zip")
//--label the zip artifact as a zip instead of the default jar
artifact in (Universal, packageZip) ~= { (art:Artifact) => art.copy(`type` = "zip", extension = "zip") }
//--add the artifact so it is included in the publishing tasks
addArtifact(artifact in (Universal, packageZip), packageZip in Universal)
//--make sure the zip gets made before the publishing commands for the added artifacts
publish := (publish dependsOn (packageBin in Universal)).value
publishM2 := (publishM2 dependsOn (packageBin in Universal)).value
publishLocal := (publishLocal dependsOn (packageBin in Universal)).value
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.