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

Recommended Articles

Create a Java Web Application with Maven from the Command Line

Learn how to create a simple Java web application using Maven's archetype-webapp and deploy it directly from the command line.

Optimize Java Application Deployment with Maven and WildFly Plugin

Learn how to configure the Maven WildFly plugin for seamless deployment of Java apps. #JavaDev #WildFly #Maven

Create and Use a Maven Multi-Module Project with EJB Application Example

Learn how to create an EJB application using Maven multi-module projects, including client and server modules. #Maven #JavaEE #WildFly31

Optimize Your Maven Builds with Apache Maven Daemon (mvnd) - A Comprehensive Guide

Learn how to install and configure mvnd for faster Maven builds. Speed up your development process today!