Skip to content

bitlap/intellij-sbt-dependency-analyzer

Repository files navigation

Sbt Dependency Analyzer for IntelliJ IDEA

logo

Project stage Build Version JetBrains Plugin Downloads

English | 中文

If you find the Sbt Dependency Analyzer interesting, please ⭐ Star it at the top of the GitHub page to support us.

Features

Support available since IntelliJ IDEA 2023.1 (231.9392.1)

  • View Dependency Tree
  • Show Conflicts
  • Search Dependencies
  • Goto Dependency (Jump to the location defined by the dependency)
  • Show Dependencies Between Modules
  • Show JAR Size
  • Dependency Exclusion (Experimental)
    • Selecting transitive dependencies in user-defined dependencies indicates exclusion, while selecting user-defined dependencies indicates deletion itself
    • Available since Sbt Dependency Analyzer 0.5.0-242.21829.142

Usage Instructions

This plugin will automatically generate project/sdap.sbt when the first analysis fails and insert the addDependencyTreePlugin (or addSbtPlugin(...)) statement into it. If generated, please do not modify or delete project/sdap.sbt.

This plugin relies on sbt-dependency-tree, a third-party plugin, which is now integrated into sbt by default (although it won't be enabled by default, as explained in this sbt issue).

Let's explore how to use it!

Default shortcut: Ctrl + Shift + L

image

More Details

The plugin utilizes the following sbt commands. However, rest assured that the plugin has been optimized to minimize the number of executions as much as possible: organization,moduleName,dependencyDot,reload,update

Advanced Setup

If you are uncertain, you can safely skip these configurations!

By utilizing configurations, analysis wait times can be significantly reduced:

settings

File Cache Timeout

If the dependent file (.dot) has not been modified within the last 3600 seconds (default value), the plugin will continue to use the existing file for analysis, otherwise the dependencyDot command will be executed, which is a certain degree of caching, but the caching may not take effect when the project first opens the analysis graph.

Organization

If you specify this value, the organization command will not be used to retrieve your project's organization.

Disable Scopes

If you do not need to analyze all scopes, simply disable the scope(s) you wish to skip.

Configurations are persistent and associated with each IntelliJ project.

Like other plugins, this one maintains its own storage in .idea/bitlap.sbt.dependency.analyzer.xml. Deleting this file will clear the cache.

Troubleshooting Issues

"Caused by: java.io.IOException: Could not create lock for ..."

Due to the plugin's requirement to use sbt shell, opening the dependency analysis view and subsequently using IntelliJ IDEA to reload or build the project may lead to the following issue:

Caused by: java.io.IOException: Could not create lock for \\.\pipe\sbt-load5964714308503584069_lock, error 5

To avoid this problem, utilize sbt shell for reloading or building the project:

settings

Unable to analyze dependencies between modules?

Ensure that you have applied one of the following settings to help identify the correct module:

  • The organization in Advanced Setup has been configured.
  • The organization value has been set in build.sbt via ThisBuild or inThisBuild.

Note: Sub modules that are not in the dependsOn of the root project will not be parsed and their dependencies will be empty.

JetBrains Support

This project is developed using JetBrains IDEA. Thanks to JetBrains for providing me with a free license, which is a strong support for me.

IntelliJ IDEA logo.