Wednesday, December 3, 2014

Run main method of a java class using maven

Exec Maven Plugin can be used.

Add following snippet to pom.xml

<project>
    ...
    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.3.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>hello.Application</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
    ...
</project>

From command line call
>mvn exec:java


No comments :

Post a Comment