问题描述
我正在为 sbt 编写插件,例如 sbt-assembly、sbt-pack 等.我想获取项目间依赖项(internalDependencyClasspath
或 projectDependencies
)并调用package
此项目上的任务并获取生成的工件的路径.我如何在其他项目上调用 package
任务?以及一般如何从父"项目中获取对子"项目的引用?
I'm writing plugin for sbt like sbt-assembly, sbt-pack, etc. I want to get inter-project dependencies (internalDependencyClasspath
or projectDependencies
) and call package
task on this projects and get path to produced artifact. How can i call package
task on other projects? and how can i get references to "child" projects from "parent" project in general?
推荐答案
你可以看看 sbt-native-packager 是如何做到的
You can have a look how sbt-native-packager does that
https://github.com/sbt/sbt-native-packager/blob/763c1c837e2f78d00cbfe54fdd07377bb21f9e70/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaApp.scala#L167
你确定这个插件不能满足你的需求吗?对我来说,它有助于构建带有运行脚本的 .tgz 存档.
Are you sure this plugin won't cover your needs? For me it helps building .tgz archive with run script inside.
以前我也使用过你提到的插件,但由于构建时间长而放弃了第一个(sbt-assembly)并且实际上并不想将所有内容合并到单个 jar 中,第二个(sbt-pack)因为它没有正确解析了传递依赖(至少之前是这样)并放置了大量重复项.
Previously I also used plugins you mentioned, but discarded the first (sbt-assembly) because of high build time and didn't actually want to merge everything into single jar, and second (sbt-pack) because it didn't properly resolved transitive dependencies (at least before) and put a lot of duplicates.
这篇关于获得对“孩子"的引用来自“父"的项目在 sbt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!