gpt4 book ai didi

sbt - 如何找到 zip 依赖路径?

转载 作者:行者123 更新时间:2023-12-02 01:58:30 25 4
gpt4 key购买 nike

在我的 SBT 构建中,我正在获取一个 zip 依赖项(之前使用 sbt-native-packager 插件构建),它使用 bundle 分类器发布在我的本地 Ivy 存储库中。

但我需要 Ivy 存储库中的依赖路径,以便解压缩它(使用 IO.unzip),将一些文件放入其中并使用 sbt-native-packager 重新打包。

我正在使用 artifacts(...) 方法来查找工件并将其添加为依赖项:

"foo" % "bar" % "1.0-SNAPSHOT" artifacts(Artifact("bar-bundle", "zip", "zip", "bundle"))

但在那之后,我有点迷路了......

我试图过滤掉 dependencyClasspath 来找到它:

val bundleFile = taskKey[File]("bundle's path")

val settings = Seq(bundleFile <<= dependencyClasspath map { _ filter (_.endsWith(".zip"))})

问题是:我在任何类路径中都找不到 zip 依赖项...我做错了什么?

我正在使用 sbt 0.13。

最佳答案

默认情况下,Zip 文件不在类路径中。包含的工件类型由 classpathTypes 配置。您可以通过以下方式向其添加“zip”:

classpathTypes += "zip"

然后它将出现在 dependencyClasspath 上。

但是,如果它真的不应该放在类路径中,您可以直接将它从更新报告中拉出。

bundleFile := {
val report: UpdateReport = update.value
val filter = artifactFilter(name = "bar-bundle", extension = "zip")
val all: Seq[File] = report.matching(filter)
all.headOption getOrElse error("Could not find bar-bundle")
}

请参阅 UpdateReport 上的文档了解详情。

关于sbt - 如何找到 zip 依赖路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18610040/

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