IntelliJ IDEA Tips & Tricks: 2. Dependency Analysis

How to analyze dependencies in IDEA using Dependency Structure Matrix and other tools.



This translation continues the IntelliJ IDEA series:



Dependency matrix


This functionality is only available in IntelliJ IDEA Ultimate, but not in the Community version.

IDEA , . , .


, , .


(Dependency Structure Matrix DSM) . -, build . , , Β«Analyze β†’ Analyze Dependency Matrix...Β». IDEA Ultimate DSM Analysis.


:



, .



IDEA , , , .


. β€” . . , . , . 99 , ... .


, , . , . .



, . , . . , , .


, , .



, . ( ), IDEA .



, , . , , .


  • ,
  • ,

, . , . , .




. , , , . , .


DSM , , . , .




. , , . DSM :



, Owner 15 Pet, Pet 5 Owner.



DSM IDEA β€” , , .


DSM. , Find usages for dependencies. IDEA / , / .


, . service, - vet. :



, .


Maven


IntelliJ IDEA Ultimate, Community .

. , , . . , , ( ). , . Maven , . :


mvn dependency:tree -Dverbose -DoutputFile=dependencies.txt

Maven , ( ):


com.vojtechruzicka:spring-boot-actuator-example:jar:1.0.0-SNAPSHOT
+- org.springframework.boot:spring-boot-starter-actuator:jar:2.0.3.RELEASE:compile
|  +- org.springframework.boot:spring-boot-starter:jar:2.0.3.RELEASE:compile
|  |  +- org.springframework.boot:spring-boot:jar:2.0.3.RELEASE:compile
|  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.3.RELEASE:compile
|  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.0.3.RELEASE:compile
|  |  |  +- ch.qos.logback:logback-classic:jar:1.2.3:compile
|  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.3:compile
|  |  |  +- org.apache.logging.log4j:log4j-to-slf4j:jar:2.10.0:compile
|  |  |  |  \- org.apache.logging.log4j:log4j-api:jar:2.10.0:compile
|  |  |  \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
|  |  +- javax.annotation:javax.annotation-api:jar:1.3.2:compile
|  |  \- org.yaml:snakeyaml:jar:1.19:runtime

, , , graphml tgf.


, , .


: verbose maven 3.x, Maven 2 .

, IDEA Maven. IntelliJ, 2019.1 , .


, pom.xml Shift + Ctrl + Alt + U ( βŒ₯ + ⇧ + ⌘ + U Mac). β†’ Diagrams β†’ Show Dependencies.


, , . . , Find , Ctrl + F.



, . , , .


β€” . , .



, , , Shift.


, .



IDEA . , , - . , :



JUnit. JUnit 3.8.1 , spring-boot-starter-test.


Maven Helper


, , . Maven Helper Vojtech Krasa. , mvn dependency:tree, .


, IDEA Community Edition IDEA, Maven .


, , pom.xml. Dependency Analyzer, .



( ). , . , .


Gradle


2019.2, IDEA Maven, Gradle. ! , Maven.


build.gradle Shift + Ctrl + Alt + U ( βŒ₯ + ⇧ + ⌘ + U Mac). β†’ Diagrams β†’ Show Dependencies.



When you build an application, the proper structuring of your dependencies is very important, since an architecture with hard and confusing dependencies can be very difficult to maintain, extend, and modify. Fortunately, IDEA can help with the structural dependency matrix, which provides a useful graphical representation of your internal dependencies.


In addition to this, you need to make sure that your external dependencies are also covered, which you can achieve by using the dependency graph for your dependency management system such as Maven.


All Articles