kuniga.me > Docs > Maven Cheatsheet
mvn archetype:generate -DgroupId=com.example -DartifactId=my-java-project -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
App.java:
App.java
public class App { public static void main( String[] args ) { System.out.println("Hello World!"); } }
pom.xml:
pom.xml
<project> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <goals> <goal>java</goal> </goals> </execution> </executions> <configuration> <mainClass>com.example.App</mainClass> </configuration> </plugin> </plugins> </build> </project>
<project> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project>
mvn compile
java is the name provided in <goal> on the build config.
java
<goal>
mvn exec:java