Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine which Maven dependency is needing a missing dependency?

I am trying to build an old Maven project and I'm getting the error:

[ERROR] Failed to execute goal on project myapp: Could not resolve dependencies for project com.initech.myapp:war:${buildVersion}: Failure to find tangosol:tangosol-coherence:jar:3.3-rc1 in http://mvnrepo.initech.com/archiva/repository/initechrepo was cached in the local repository, resolution will not be reattempted until the update interval of initechrepo has elapsed or updates are forced -> [Help 1]

I looked in the pom.xml of MyApp and there is no mention of "tangosol" and there is no parent POM so I figure this must be a transitive dependency.

Normally, I can use the Maven Dependency plugin on the command line with mvn dependency:tree to display transitive dependencies. However, since the dependency is missing, the build fails and errors out instead of displaying the tree.

How can I get the cause of missing transitive dependency even if the build is failing?


EDIT: I am aware of why it failed, the artifact is missing from our local repository and the central repository, the question is which of my dependencies is asking for it.

like image 335
Sled Avatar asked Jul 31 '13 19:07

Sled


People also ask

How can you determine which POM has the missing transitive dependency?

Q13. How do I determine which POM contains missing transitive dependency? Ans. If its already there in Maven local repository, We can add that as a dependency in the project pom file with its Group Id, Artifact Id and version.

How do you stop optional dependency?

In order to exclude these special dependencies from the main project, we can apply Maven's <optional> tag to them. This forces any user who wants to use those dependencies to declare them explicitly. However, it does not force those dependencies into a project that doesn't need them.

How do you analyze a dependency tree in Maven?

A project's dependency tree can be filtered to locate specific dependencies. For example, to find out why Velocity is being used by the Maven Dependency Plugin, we can execute the following in the project's directory: mvn dependency:tree -Dincludes=velocity:velocity.

How do you find transitive dependencies?

You can get this information in the Maven Tool Window. First go to View → Tool Windows → Maven, to make sure that the Maven window is visible. The top-level elements in the tree are your direct dependencies, and the child elements are the transitive dependencies.


1 Answers

There should be a better way, but if you run the command in debug mode (ie -X so the full command becomes mvn -X dependency:tree) then you'll see the trace printed out before the build dies:

    ...
[DEBUG]    org.springmodules:spring-modules-cache:jar:0.9:compile
[DEBUG]       opensymphony:oscache:jar:2.3:compile
[DEBUG]       tangosol:tangosol-coherence:jar:3.3-rc1:compile
[DEBUG]       oro:oro:jar:2.0.8:compile
[DEBUG]       org.apache.jcs:jcs:jar:1.3:compile
[DEBUG]          concurrent:concurrent:jar:1.0:compile
    ...

better answers are welcome.

like image 113
Sled Avatar answered Oct 12 '22 22:10

Sled