JLM*_*JLM 6 scala sbt sbt-native-packager
我试图通过universal:packageBin任务将sbt-native-packager插件生成的zip文件发布到存储库.
我像这样配置了我的项目:
publishTo := Some("Repo" at "http://repo")
publishMavenStyle := true
packagerSettings
packageArchetype.java_application
Run Code Online (Sandbox Code Playgroud)
我正在努力尝试使用发布任务和packageBin任务来创建一个新的sbt任务(名为publishZip)来发布zip文件.我怎样才能做到这一点?
将以下行添加到您的sbt构建中(围绕packagerSettings应该没问题)
deploymentSettings
根据您的要求,您可能不需要定义可以运行的publishZip任务
sbt universal:publish 哪个应该只发布zippublish <<= publish.dependsOn(publish in config("universal"))然后运行sbt publish.
为了完整起见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
Run Code Online (Sandbox Code Playgroud)
此解决方案的关键部分来自 yanns和dgrandes的评论
| 归档时间: |
|
| 查看次数: |
4355 次 |
| 最近记录: |