scala – 有没有办法通过sbt插件获取项目的所有依赖项?
发布时间:2020-12-16 18:15:28 所属栏目:安全 来源:网络整理
导读:我想写一个sbt插件,在其中我需要获取当前项目的所有依赖项的列表(有一些信息,是可能的).可能吗? 解决方法 在我们的项目中,我们使用更新任务来获取库依赖项: (update) map { (updateReport) = updateReport.select(Set("compile","runtime")) foreach { src
我想写一个sbt插件,在其中我需要获取当前项目的所有依赖项的列表(有一些信息,是可能的).可能吗?
解决方法
在我们的项目中,我们使用更新任务来获取库依赖项:
(update) map { (updateReport) => updateReport.select(Set("compile","runtime")) foreach { srcPath => /* do something with it */ } } 希望这有助于一个开始. [编辑]以下是如何将此功能添加到您的任务的简单示例: 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) } } )) 要使用该任务,只需将testSettings添加到项目中即可. 有关任务的更多信息,请参阅sbt documentation.有关更新任务的更多信息,请参见here. [EDIT2]更新任务仅获取库依赖项.我从未尝试过外部 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |