Gradle Check Unused Dependencies



It’s worth mentioning that while Gradle can generate a dependency verification file for you, you should always check whatever Gradle generated for you because your build may already contain compromised dependencies without you knowing about it. This is a follow-up to The proper care and feeding of your Gradle build, in which I wrote about how to use the Dependency Analysis Gradle Plugin to help maintain a healthy build for your Android, Java, and Kotlin projects. In this first of a series of posts, we will discuss how that plugin works. 1 To begin, we will take a look at bytecode analysis with the ASM library, and how it is essential.

  1. Gradle Exclude Jar Dependencies
  2. Gradle Check Unused Dependencies Java
  3. Gradle Check Unused Dependencies Python
Gradle Check Unused Dependencies

You can work with Gradle dependencies in the diagram format. It might be helpful when you have a large project and want to see the whole picture of how dependencies (including the transitive ones) are connected inside the project.

  1. In the Gradle tool window, select a project, on the toolbar, click or select the Show Dependencies option from the context menu.

    You can select the Show Dependecies Popup(Ctrl+Alt+U) option to open the graph in a separate window. To close the popup, press Escape.

  2. In the diagram window, IntelliJ IDEA displays all project dependencies including the transitive ones.

    When you navigate to a dependency in a graph, IntelliJ IDEA displays its version, group and artifact IDs.

Gradle check unused dependencies python

Use the diagram window toolbar to manage the diagram. You can change the size of a diagram, export it to a file, see only a part of the diagram you are interested in, and so on.

Change the visibility level

Gradle Check Unused Dependencies

You can change the visibility level and, for example, view dependencies that have a specific scope (compile, test, and so on).

Gradle Exclude Jar Dependencies

Hold down Alt and move the cursor to zoom in on the parts of the diagram.

In Android and Kotlin projects IntelliJ IDEA supports only the default visibility level.

Gradle Check Unused Dependencies Java

  1. In the diagram window, select the project and click .

  2. From the list, select the dependency scope you want to see. IntelliJ IDEA displays only the specified dependency scope.

Show path from selection to root

You can select dependencies and see how they are connected to the root.

  1. In the diagram window, select a dependency for which you want to see the connection to a project. If you want to select several dependencies at once, hold down Shift and make the selection.

  2. On the toolbar, click .

Show neighbors of the selected nodes

You can select dependencies and see what other dependencies are connected to the selected nodes. It might be helpful if you have a large diagram and want to focus on just a part of it.

  1. In the diagram window, select a dependency you need. If you want to select several dependencies at once, hold down Shift and make the selection.

  2. On the toolbar, click .

Gradle Check Unused Dependencies Python

. CheckGradle

Search for a specific dependency in the graph

  1. In the diagram window, press Ctrl+F to open the Diagram Elements popup.

  2. Start typing a name of a dependency you want to find, select the one you need from the list of search results and press Enter. IntelliJ IDEA locates the needed dependency in the graph.