How to invoke a Maven plugin from the Command Line?

In this short tech tip, we will learn how to call a Maven plugin from the Command Line (i.e. a Plugin which is not included in your pom.xml file)

With maven, you normally invoke plugin’s goals in this way:

mvn myplugin:myGoal

 so, for example, if you have declared the WildFly Maven plugin in your configuration:

<plugin>
        <groupId>org.wildfly.plugins</groupId>
        <artifactId>wildfly-maven-plugin</artifactId>
        <version>2.0.1.Final</version>
</plugin>

 Then, you could invoke the “deploy” goal as follows:

mvn wildfly:deploy

However, it’s possible to invoke plugin goals from the Command Line, without any definition in the pom.xml. How? simply replace your plugin alias with its GAV (groupId, artifactId, version).

So, if you were to deploy an application into WildFly, without a plugin definition, here’s how to do it:

mvn org.wildfly.plugins:wildfly-maven-plugin:2.0.1.Final:deploy
Found the article helpful? if so please follow us on Socials