How to list active sub-modules in a Maven project?

前端 未结 8 1269
长发绾君心
长发绾君心 2020-12-24 13:26

I have a complex project where there are many directories that have POM files, but only some of which are sub-modules (possibly transitively) of a particular parent project.

相关标签:
8条回答
  • 2020-12-24 14:03

    The solution I found is quite simple:

    mvn -B -f "$pom_file" org.codehaus.mojo:exec-maven-plugin:1.4.0:exec \
        -Dexec.executable=/usr/bin/echo \
        -Dexec.args='${basedir}/pom.xml'| \
        grep -v '\['
    

    This is a little bit tricky due to the need to grep out the [INFO|WARNING|ERROR] lines and make it usable for scripting but saved me a lot of time since you can put any expression there.

    0 讨论(0)
  • 2020-12-24 14:07

    This is quite simple but it only gets the artifactId, from the root (or parent) module:

    mvn --also-make dependency:tree | grep maven-dependency-plugin | awk '{ print $(NF-1) }'

    If you want the directories

    mvn -q --also-make exec:exec -Dexec.executable="pwd"

    0 讨论(0)
提交回复
热议问题