在我们的项目中,我们使用更新任务来获取库依赖项:
(update) map {
(updateReport) =>
updateReport.select(Set("compile", "runtime")) foreach { srcPath => /* do something with it */ }
}
Run Code Online (Sandbox Code Playgroud)
希望这有助于一个开始.
[编辑]以下是如何将此功能添加到您的任务的简单示例:
val depsTask = TaskKey[Unit]("find-deps", "finds the dependencies")
val testConf = config("TestTasks") hide
private lazy val testSettings = inConfig(testConf)(Seq(
depsTask <<= (update) map {
(updateReport) =>
updateReport.select(Set("compile", "runtime")) foreach { srcPath => println("src path = " + srcPath) }
}
))
Run Code Online (Sandbox Code Playgroud)
要使用该任务,只需将testSettings添加到项目中即可.
有关任务的更多信息,请参阅sbt文档.有关更新任务的更多信息,请参见此处.
[EDIT2]更新任务仅获取库依赖项.我从未尝试过外部项目依赖(比如git存储库).也许您需要以下内容:查找项目工件.任务allTheArtifacts找到项目的工件和项目依赖项的工件.