Elyor Murodov
Elyor Murodov

Reputation: 1028

IntelliJ: Easier way to check if a maven artifact is included in the project?

Currently, I can use "Find in Path" feature and type the name of the artifact (or search in the pom.xml) to check if the project has that dependency, but this doesn't work for transitive dependencies.

I can generate the dependency tree in IntelliJ (or on command line), but that requires me to lookup the artifact through the entire tree/list, not so convenient.

Is there an easy (more fluent) way of checking this?

Upvotes: 2

Views: 4468

Answers (4)

jchacana
jchacana

Reputation: 49

Another couple of options:

  • Showing the dependency diagram (secondary click on Maven Projects menu, where your module is shown -> Show dependencies). Once under this view, you can ctrl-f. It starts by showing base packages

  • Make use of "Maven Helper" plugin. Once installed, open your pom file and you'll find now a "Dependency Analyzer" tab which is pretty much like the dependency tree function from Eclipse

Upvotes: 0

halil
halil

Reputation: 800

  1. Ctrl + Shift + N (Enter your module/project name)
  2. Select related pom file
  3. Ctrl + Alt + U (Mvn Dependency dialog will open)
  4. In the dialog Ctrl + F (Enter dependency you want to search)

You will see if your desired dependency exist in that module/project and where does it come from transitively.

Upvotes: 0

jwenting
jwenting

Reputation: 5663

Alternative to @vikingsteve's answer, in the right hand pane, under the Maven projects tab, click open any module's entry and look under dependencies.

This gives a more fine grained dependency tree, especially in multi-module projects, showing you which dependency is pulled in from where (including transitive dependencies) and also excluded dependencies per module.

It (just an example) allows me to see that hibernate-core 4.3.11.Final creates a transitive dependency on dom4j 1.6.1 and that the transitive dependency on the same in hibernate-entitymanager 4.3.11.Final is ignored because of that.

That can at times help figure out where a specific version of a specific transitive dependency comes from that you don't want because you're already explicitly adding another version of the same library.

Upvotes: 1

vikingsteve
vikingsteve

Reputation: 40408

Yes, just look in the project pane (left hand side).

enter image description here

Under the project structure you will see External Libraries - just expand this tree node and you will see all maven depepencies there. They start with Maven: - just type to search :)

For a proper analysis (showing the location of transitive deps) you can run mvn dependency:tree from the command line.

Upvotes: 5

Related Questions