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

好久不见. 提交于 2019-12-07 20:22:33

问题


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

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/36936238/create-a-list-of-artifacts-that-are-build-by-a-maven-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!