0

SBT uses Ivy under the hood for dependencies. Ivy can generate lots of dependency reports. How can I get access to that via SBT?

In general, if I want to use an Ivy command via SBT, how can I do it? Can I generate a POM from the SBT dependencies?

UPDATE: My goal is to debug and manually fine tune problems, not to be part of any automated tasks

UPDATE 2: To debug, I'd like to see the whole transitive dependency chain, not just the top level dependencies.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
SRobertJames
  • 8,210
  • 14
  • 60
  • 107
  • Do you want to use those reports in your task / command or do you want to use it to analyse dependencies? In general there is a [ivySbt](https://github.com/sbt/sbt/blob/0.13/main/src/main/scala/sbt/Keys.scala#L245) task, which can return IvySbt, which can be used to access Ivy, but if you want to manually analyse dependencies I guess there is a better way to do it. – lpiepiora Jun 26 '14 at 17:45
  • Could you check if my answer would help you? Additionally you could also look at the [sbt-dependency-graph](https://github.com/jrudolph/sbt-dependency-graph) – lpiepiora Jun 26 '14 at 18:37

2 Answers2

2

There are several options when debugging dependencies.

Using sbt-dependency-graph

You can use whatDependsOn <organization> <module> <revision> command to see where the dependency is used.

For example I have a transitive dependency to org.apache.httpcomponents:httpcore:4.0.1. To see what includes it I can use whatDependsOn.

[play-slick-advanced] $ whatDependsOn org.apache.httpcomponents httpcore 4.0.1
[info] org.apache.httpcomponents:httpcore:4.0.1
[info]   +-oauth.signpost:signpost-commonshttp4:1.2.1.2
[info]   | +-com.typesafe.play:play_2.10:2.2.0
[info]   |   +-com.typesafe.play:play-java_2.10:2.2.0
[info]   |   | +-default:play-slick-advanced_2.10:1.0.1 [S]
[info]   |   | 
[info]   |   +-com.typesafe.play:play-jdbc_2.10:2.2.0
[info]   |   | +-com.typesafe.play:play-slick_2.10:0.5.0.8 [S]
[info]   |   |   +-default:play-slick-advanced_2.10:1.0.1 [S]
[info]   |   |   +-org.virtuslab:unicorn_2.10:0.4 [S]
[info]   |   |     +-default:play-slick-advanced_2.10:1.0.1 [S]
[info]   |   |     
[info]   |   +-com.typesafe.play:play-slick_2.10:0.5.0.8 [S]
[info]   |   | +-default:play-slick-advanced_2.10:1.0.1 [S]
[info]   |   | +-org.virtuslab:unicorn_2.10:0.4 [S]
[info]   |   |   +-default:play-slick-advanced_2.10:1.0.1 [S]
[info]   |   |   
[info]   |   +-default:play-slick-advanced_2.10:1.0.1 [S]
[info]   |   
[info]   +-org.apache.httpcomponents:httpclient:4.0.1
[info]     +-oauth.signpost:signpost-commonshttp4:1.2.1.2
[info]       +-com.typesafe.play:play_2.10:2.2.0
[info]         +-com.typesafe.play:play-java_2.10:2.2.0
[info]         | +-default:play-slick-advanced_2.10:1.0.1 [S]
[info]         | 
[info]         +-com.typesafe.play:play-jdbc_2.10:2.2.0
[info]         | +-com.typesafe.play:play-slick_2.10:0.5.0.8 [S]
[info]         |   +-default:play-slick-advanced_2.10:1.0.1 [S]
[info]         |   +-org.virtuslab:unicorn_2.10:0.4 [S]
[info]         |     +-default:play-slick-advanced_2.10:1.0.1 [S]
[info]         |     
[info]         +-com.typesafe.play:play-slick_2.10:0.5.0.8 [S]
[info]         | +-default:play-slick-advanced_2.10:1.0.1 [S]
[info]         | +-org.virtuslab:unicorn_2.10:0.4 [S]
[info]         |   +-default:play-slick-advanced_2.10:1.0.1 [S]
[info]         |   
[info]         +-default:play-slick-advanced_2.10:1.0.1 [S]

Just using sbt

I think the fact that the reports are produced is a cool and underestimated feature. They are generated in the target/resolution-cache/reports directory, after the update task.

This is step by step guide on how to use them.

Clean project

Step1

Run update and go to target/resolution-cache/reports

Step2

Open any of the XML files with Firefox

This part is a bit tricky, for some reason some browsers will render the correct report, and some will read the file as an XML file. Not sure why it is like that, but for sure Firefox works well. Doesn't really matter which file you'll open as you can switch between them using tabs in the rendered page.

Step3

lpiepiora
  • 13,659
  • 1
  • 35
  • 47
0

Run the package task, and it will produce the POM in the target\scala* directory.

joescii
  • 6,495
  • 1
  • 27
  • 32