IntelliJ IDEA: Analyzing Dependencies

IntelliJ IDEA: Analyzing Dependencies


IntelliJ IDEA: Analyzing Dependencies

If you’re working on a real world project, you’re probably using external dependencies. You might need to analyze which dependencies your application uses. For example, you may want to find out how a particular version of a dependency ended up in your application. Let’s take a look at how IntelliJ IDEA can help you to analyze dependencies.

For more information, take a look at:
• Maven Dependency Analyzer: https://jb.gg/txz4bm
• Gradle Dependency Analyzer: https://jb.gg/oljl2g
• Managing Dependencies:    • IntelliJ IDEA: Managing Dependencies  
• Viewing Dependencies:    • IntelliJ IDEA: Viewing Dependencies  

Example project:
https://github.com/spring-projects/sp


*Author: Marit van Dijk

Download IntelliJ IDEA: https://jb.gg/download-intellij-idea

Join us:

Website https://jb.gg/website
Blog https://jb.gg/blog
Twitter https://twitter.com/intellijidea
Facebook https://www.facebook.com/IntelliJIDEA/

#intelliJIDEA #intelliJ #jetbrains #java #programming


Content

3.83 -> If you're working on a real world project, you're probably using external dependencies.
9.21 -> You might need to analyze which dependencies your application uses.
13.08 -> For example, you may want to find out how a particular version of a dependency ended
18.42 -> up in your application.
19.96 -> Let's take a look at how IntelliJ IDEA can help you to analyze dependencies.
24.9 -> We can view our dependencies in the Maven tool window.
27.59 -> Here, we can expand dependencies to show their transitive dependencies, or collapse them
32.54 -> again.
33.54 -> We can open the Dependency Analyzer from the Maven tool window by clicking the Analyze
38.579 -> Dependencies… button.
40.05 -> This will open the Dependency Analyzer showing the Resolved Dependencies on the left and
45.16 -> their Usages on the right.
47.35 -> Alternatively, we can right-click a dependency in the Maven tool window and select Analyze
52.8 -> Dependencies from the context menu.
55.21 -> This will open the Dependency Analyzer with the dependency selected.
59.059 -> Let's hide all tool windows so we can focus.
62.05 -> We can view the dependencies as a tree and expand or collapse them as needed.
67.05 -> We can also click the View Options button and toggle whether we want to show the GroupId
71.97 -> or not.
73.47 -> To see where we are getting a specific version of a particular library, we can search for
78.189 -> that dependency.
79.67 -> For example, when we search for "log4j" we see that we are only getting it via this spring-boot-starter,
85.82 -> and it's a version newer than the one where log4shell was fixed.
89.57 -> Yeay!
90.57 -> We might only want to look at dependencies that have conflicts.
93.46 -> When we select the Show Conflicts Only button, we see only dependencies that have conflicts.
98.45 -> Here we see that there is a conflict with the checker framework dependency.
102.299 -> Fortunately, it's been resolved; we see that one version is greyed out.
106.729 -> If we go back to the Maven tool window, we see that this version has been omitted for
111.64 -> conflict.
113.15 -> We can see that the version we are using is 3.5.0 which we get from postgres.
119.6 -> We can also select a scope (for example, if we want to look at our test dependencies or
125.14 -> exclude them from analysis).
127.82 -> Since we've opened the Dependency Analyzer from the Maven tool window, we see the Maven
132.75 -> scopes.
133.75 -> When we open the Dependency Analyzer from the Gradle tool window, the list of scopes
137.99 -> will contain Gradle scopes.
140.39 -> For more context, we can click a specific dependency and select Open Maven Config to
146 -> open its pom.xml or Go to Maven Dependency to open the location in the pom.xml where
152.11 -> this dependency is declared.
154.269 -> If you are using IntelliJ IDEA Ultimate, you can also view your dependencies as a diagram.
160.97 -> Let's open IntelliJ IDEA Ultimate to have a look.
164.8 -> We can open Diagrams either by right-clicking the project in the Project tool window and
169.46 -> selecting Diagrams | Show Diagrams, or by using the shortcut ⌥ ⇧ ⌘ U (on Mac)
178.06 -> or Ctrl+Alt+Shift+U (on Windows/Linux).
180.459 -> You'll notice this gives you several diagram options to choose from.
184.9 -> In this case, we're interested in the Gradle dependencies.
188.73 -> Let's Hide All Windows again so we can focus on the diagram.
192.599 -> The project we're looking at pulls in a lot of transitive dependencies, so the diagram
197.299 -> is quite large.
199.05 -> We can zoom in and out using the + and - keys, or the + and - buttons in the diagram window.
206.34 -> We want to look for a specific dependency and see where we get it from.
210.83 -> We can search for a dependency using Ctrl+F to find it in the diagram.
215.81 -> We can check the path for this dependency and click related dependencies to follow this
220.54 -> path to the root.
222.33 -> We have other options to look into specific dependencies.
226 -> For example, we can zoom in on a specific dependency and the related nodes.
231.23 -> Right-click the dependency you're interested in, and from the context menu, select Analyze
235.93 -> graph > Focus on Node Neighbourhood.
238.439 -> Let's look at both directions.
240.35 -> When we are done, we can Drop focus.
243.2 -> We can change the visibility level, for example if we want to focus on compile or runtime
249.61 -> dependencies.
250.61 -> IntelliJ IDEA can help you analyze dependencies in multiple ways.
255.299 -> Thanks for watching!

Source: https://www.youtube.com/watch?v=La3Cp-O05eQ