gpt4 book ai didi

playframework - 如何将 Play 的 "dist"zip 文件发布到远程 Maven 存储库?

转载 作者:行者123 更新时间:2023-12-04 22:45:52 24 4
gpt4 key购买 nike

我在将 Play 的应用程序分发 zip 文件发布到远程 maven 存储库时遇到问题。

有很多关于这方面的帖子和博客,但似乎没有什么对我有用。它们要么不完整,要么过时。

例如,这里有一段摘录:

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

val myDistSettings = Seq[Setting[_]] (
publish <<= (publish) dependsOn play.Project.dist,
publishLocal <<= (publishLocal) dependsOn play.Project.dist,
artifact in distHack ~= { (art: Artifact) =>
art.copy(`type` = "zip", extension = "zip")
},
distHack <<= (distDirectory, version) map { (d, v) =>
val packageName = "%s-%s" format(projectName, v)
val zip = d / (packageName + ".zip")
zip
}
) ++ Seq(addArtifact(artifact in distHack, distHack).settings: _*)

play.Project.dist 在最新版本的 play 中不再是对“dist”的有效引用。

另外,如何正确指定“distDirectory”以及从何处获取“projectName”?

此外,大多数示例都旨在将代码包含在构建的 .scala 文件中。我试图变得简单并在我的构建的 .sbt 文件中指定它。

如果这种方法适用于任何人,您能否发布一个完整的示例?

谢谢!

最佳答案

我在 build.sbt 中使用此配置将 zip 文件发布到远程 maven 存储库。

lazy val dist = com.typesafe.sbt.SbtNativePackager.NativePackagerKeys.dist

publish <<= (publish) dependsOn dist

publishLocal <<= (publishLocal) dependsOn dist

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

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

val distHackSettings = Seq[Setting[_]] (
distHack <<= (target in Universal, normalizedName, version) map { (targetDir, id, version) =>
val packageName = "%s-%s" format(id, version)
targetDir / (packageName + ".zip")
}) ++ Seq(addArtifact(artifact in distHack, distHack).settings: _*)

seq(distHackSettings: _*)

如果您只想发布 zip 文件,而不是其他人工制品,请将其添加到 build.sbt:
publishArtifact in (Compile, packageBin) := false

publishArtifact in (Compile, packageDoc) := false

publishArtifact in (Compile, packageSrc) := false

使用 sbt publish将 zip 发送到远程仓库。当您使用 sbt-release 时,它也像魅力一样工作.

关于playframework - 如何将 Play 的 "dist"zip 文件发布到远程 Maven 存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26452140/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com