How to execute maven plugin execution directly from command line?

artemb picture artemb · Jul 2, 2010 · Viewed 81.2k times · Source

I have a plugin (antrun) with an execution configured which has an id and is not bound to any phase. Can I execute this execution directly from the command line?

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>my-execution</id>
      ...
    </execution>
  </executions>
</plugin>

An run it with something like:

mvn my-execution

or at least

mvn magicplugin:execute -DexecutionId=my-execution

Answer

Joe picture Joe · Feb 21, 2015

This functionality has been implemented as MNG-5768, and is available in Maven 3.3.1.

The change will:

extend direct plugin invocation syntax to allow optional @execution-id parameter, e.g., org.apache.maven.plugins:maven-remote-resources-plugin:1.0:process@executionId.

So, in your case:

mvn antrun:run

uses the default-cli execution ID, and:

mvn antrun:run@my-execution

uses the execution configured in your pom.