A Maven lifecycle extension that dumps the Maven model as JSON.
It is intended to quickly retrieve the list of all artifacts.
Preferred way is to add a profile to your top-level pom like this:
<profiles>
<profile>
<id>dump-model</id>
<build>
<plugins>
<plugin>
<groupId>org.caffinitas.dump-maven-model</groupId>
<artifactId>dump-maven-model</artifactId>
<version>0.1.0</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
And run the following to get the dump the whole Maven model as JSON.
mvn -Pdump-model validate -q > model.json
Setting the property dump-model.all-projects
to false
restricts the output to the root project.
Example:
mvn -Ddump-model.all-projects=false -Pdump-model validate -q > model.json
The JSON model currently contains two top-level properties:
model
mirroring (most of) the Maven model including all modules. Property names are the same as in the Maven model classes (org.apache.maven.model.Model
and related), but not all available properties are mapped.allModelArtifacts
list containing all artifacts that the Maven model contains, including the artifact of the top-level module and all submodules.
jq -r '.allModelArtifacts[].id' < model.json
jq -r '.allModelArtifacts[].artifactId' < model.json
As above, but prefixed with :
.
jq -r '":" + .allModelArtifacts[].artifactId' < model.json
As above, but a single, comma-separated list.
jq -r '[":" + .allModelArtifacts[].artifactId] | join(",")' < model.json
You could also the exec-maven-plugin, however this will take quite a while.
man -q org.codehaus.mojo:exec-maven-plugin:1.6.0:exec@noid -Dexec.executable=echo -Dexec.args='${project.groupId}:${project.artifactId}:${project.version}:${project.packaging}'