Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all `dependencyManagment` in Maven?

I use some BOM dependencies in my Maven project, such as:

<dependencyManagement>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring-boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
    ...
</dependencyManagement>

Whenever I need to add a dependency, I want to know if that dependency has been declared in any dependencyManagement I imported, so that I don't need to specify version for it.

Now I'm doing that manually, go to the source of those BOM files to check, but sometimes one BOM imports other BOMs as well, for example: spring-boot-dependencies imports netty-bom and jackson-bom. So I want to know is there a way to list(flatten) all my dependencyManagement?

like image 626
Elderry Avatar asked Oct 29 '25 03:10

Elderry


1 Answers

I think the best you can do with maven is mvn help:effective-pom and grep for the dependency in question. It will show you the effective pom, including the expanded BOM dependencyManagement.

Also, if you use an IDE like IntelliJ, it will show an "arrow up" symbol for managed dependencies, including those pulled in via BOM.

like image 181
gjoranv Avatar answered Nov 01 '25 11:11

gjoranv