[英]Publish zip created by sbt-native-packager
I am trying to publish to a repository the zip file generated by the sbt-native-packager plugin through universal:packageBin task.我正在尝试将sbt-native-packager插件通过Universal:packageBin任务生成的 zip 文件发布到存储库。
I configured my project like this:我这样配置我的项目:
publishTo := Some("Repo" at "http://repo")
publishMavenStyle := true
packagerSettings
packageArchetype.java_application
I am struggling trying to create a new sbt task (named publishZip) using publish task and packageBin task to publish the zip file.我正在努力尝试使用发布任务和 packageBin 任务来创建一个新的 sbt 任务(名为 publishZip)来发布 zip 文件。 How can I achieve this ?
我怎样才能做到这一点?
Add the following line to your sbt build (around packagerSettings should be fine)将以下行添加到您的 sbt 构建中(在 packagerSettings 周围应该没问题)
deploymentSettings
Depending on what you want to do you may not need to define the publishZip task you could run根据您想要执行的操作,您可能不需要定义可以运行的 publishZip 任务
sbt universal:publish
which should only publish the zip sbt universal:publish
应该只发布 zippublish <<= publish.dependsOn(publish in config("universal"))
publish <<= publish.dependsOn(publish in config("universal"))
Then run sbt publish.然后运行 sbt 发布。
For completeness sake deploymentSettings
(and packagerSettings
) come from com.typesafe.sbt.SbtNativePackager
which is useful to know if you use a scala build :)为了完整起见,
deploymentSettings
(和packagerSettings
)来自com.typesafe.sbt.SbtNativePackager
这对于了解您是否使用 scala 构建很有用:)
The deploymentSettings
worked however I wanted to refine the settings. deploymentSettings
有效,但我想优化设置。 It seems there were several issues going on.似乎有几个问题正在发生。 I and finally came up with the following solution:
我终于想出了以下解决方案:
//--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
The key pieces of this solution came from a comment from yanns and dgrandes此解决方案的关键部分来自 yanns和dgrandes的评论
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.