I want to write an sbt plugin, and inside it I need to get the list of all dependencies of current project (with some info, is possible). Is it possible?
In our project we use the update task to get the library dependencies:
(update) map {
(updateReport) =>
updateReport.select(Set("compile", "runtime")) foreach { srcPath => /* do something with it */ }
}
Hope this helps for a start.
[EDIT] Here is a simple example how to add this functionality to your task:
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) }
}
))
To use the task just add testSettings to your project.
For more about tasks see the sbt documentation. More information about the update task can be found here.
[EDIT2] The update task only gets the library dependencies. I never tried out external project dependencies (like to a git repository). Maybe you need something like the following: find project artifacts. The task allTheArtifacts finds the artifacts of the project and the artifacts of its project dependencies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With