I need to extract the artifactId from all the poms in a multimodule project.
The project structure is similar to this but the structure can be different (It's depends of the project):
project
|------->pom.xml
|------->subproject1
|------->pom.xml
|------->folder1
|------->pom.xml
|------->subproject2
|------->pom.xml
|------->folder2
|------->pom.xml
|------->subproject3
|------->pom.xml
|------->folder3
|------->pom.xml
|------->subproject4
|------->pom.xml
|------->folder4
|------->pom.xml
|------->subproject5
|------->pom.xml
|------->folder5
|------->pom.xml
MVN_ARTIFACTID=$(mvn -q \
-Dexec.executable="echo" \
-Dexec.args='${project.artifactId}' \
--non-recursive \
org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)
Just remove non recursive option :
MVN_ARTIFACTID=$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.artifactId} ##' org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)
echo $MVN_ARTIFACTID| sed 's/##/\n/g'
Added ## as a small hack so that second line can give artifactId names in more readable format. Else all modules will be echoed in same line.
Module-1
Module-2
Module-3