How to determine which artifacts are built from the maven reactor plan (i.e. including auxiliary modules)?

(Note: this question was originally posed by Dan Allen on Google+ here: https://plus.google.com/114112334290393746697/posts/G6BLNgjyqeQ )

If I ran 'mvn install', what artifacts would he install? Or, if I ran "mvn deploy", what artifacts would he deploy?

Most likely, it will be a fairly simple recording plugin, but I do not want to invent it if it is already available programmatically. It seems that it should be easily accessible somewhere.

+3
source share
1 answer

, maven . , , package.

- , , , , . install. verify install, mojo .

, url, :

mvn verify deploy:deploy -DaltDeploymentRepository=snapshots::default::file:///home/jh/Temp/repository

maven, , :

/**
 * @goal list-artifacts
 * @phase verify
 */
public class ListArtifactsMojo extends AbstractMojo {

    /**
     * @parameter default-value="${project}"
     * @required
     * @readonly
     */
    MavenProject project;

    public void execute() throws MojoExecutionException, MojoFailureException {
        Collection<Artifact> artifacts = new ArrayList<Artifact>();
        artifacts.add(project.getArtifact());
        artifacts.addAll(project.getAttachedArtifacts());

        for (Artifact artifact : artifacts) {
            System.out.println("Artifact: " + artifact);
        }
    }
}
+2

All Articles