简体   繁体   中英

Create a list of artifacts that are build by a maven project

Is there a way to create a list of all artifacts that are created by running

mvn clean install

similar to the output of :

mvn mvn dependency:tree/list

There is a way to do that:

mvn -q -Dexec.executable='echo' -Dexec.args='${project.groupId} ${project.version} ${project.artifactId} ${project.packaging}' --non-recursive exec:exec

If you want it for all artifacts in your project including sub-folders remove --non-recursive .

It can be achieved by writing a maven extension by extending org.apache.maven.AbstractMavenLifecycleParticipant which will run at the end of maven build afterSessionEnd and using MavenSession.getAllProjects(), Artifact.getArtifact(), getAttachedArtifacts(), getGroupID(), getArtifactId(), getClassifier(), getType() you can loop through all the projects and get the details for each artifact generated.
make sure to set the correct profile(if you have any) to not miss any info about the artifacts like reported here get classifier/id of maven assembly artifact

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM