exec-maven-plugin in Maven

exec-maven-plugin – This plugin is used to call the main method of any class during any phase of the build life cycle. Sometimes, we need to perform certain tasks before executing certain Maven phases. So you can use this plugin to execute custom code. Suppose you want to invoke below class that contain main method.
package operations;

public class LaunchProcess {

    public static void main(String[] args) {
        System.out.println("This will be invoked " +
                "by maven-exec-plugin");

To execute above main method, you can add below plugin block in Maven POM.XML file. Note that we have configured phase as compile. That means the plugin will be invoked right at the end of compile phase. Also notice that we have given a goal as java which means that plugin is going to execute some class file. Inside the configuration element, we have given the name of above class.

If we execute compile phase, you will see that code in the main method gets executed
Complex problems, Simple Solutions