How do I show the Maven POM hierarchy?

后端 未结 2 1763
南旧
南旧 2020-12-29 03:10

I\'m doing some scripting and I need to get a list of all the parent poms for any given pom. The dependency plugin seems to be only interested in the dependencies that are

2条回答
  •  青春惊慌失措
    2020-12-29 04:01

    Basic solution

    mvn org.apache.maven.plugins:maven-dependency-plugin:3.1:display-ancestors
    

    If your project defines version 3.1 or later you can use:

    mvn dependency:display-ancestors
    

    The output looks similar to:

    [INFO] Ancestor POMs: org.springframework.boot:spring-boot-starter-parent:1.4.0.RELEASE <- org.springframework.boot:spring-boot-dependencies:1.4.0.RELEASE

    Improved solution

    The hierarchy-maven-plugin (that I wrote) can display additional information about imported poms like this :

    [INFO] Displaying hierarchy. Set level=full to display dependencies in dependencyManagement
    [INFO]  PARENT org.springframework.boot:spring-boot-samples:1.4.1.BUILD-SNAPSHOT
    [INFO]    PARENT org.springframework.boot:spring-boot-starter-parent:1.4.1.BUILD-SNAPSHOT
    [INFO]      PARENT org.springframework.boot:spring-boot-dependencies:1.4.1.BUILD-SNAPSHOT
    [INFO]        IMPORT org.springframework:spring-framework-bom:4.3.3.BUILD-SNAPSHOT
    [INFO]        IMPORT org.springframework.data:spring-data-releasetrain:Hopper-BUILD-SNAPSHOT
    [INFO]          PARENT org.springframework.data.build:spring-data-build:1.8.4.BUILD-SNAPSHOT
    [INFO]        IMPORT org.springframework.integration:spring-integration-bom:4.3.1.RELEASE
    [INFO]        IMPORT org.springframework.security:spring-security-bom:4.1.3.RELEASE
    

    Details are here : https://github.com/ExampleDriven/hierarchy-maven-plugin

提交回复
热议问题