Setup A New Project with Maven
Create a Simple Maven Project
I always find myself searching for these simple commands. You could do this through your IDE as well, but that often ends up in frustration. I usually just start at the command line..
To setup a new project try the following. Don't forget to update for your needs.
mvn -B archetype:generate \ -DarchetypeGroupId=org.apache.maven.archetypes \ -DgroupId=com.mycompany.app \ -DartifactId=my-app
Sometimes a one liner is just easier.
mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=net.largepixels.jaxb.example01.pizza.api.pizzaorders -DartifactId=pizza-orders Create New Multi Module Project
Create Multi Module Maven Project
Creating a multi module pom from scratch can be a pain. This snippit will take you through it interactivly.
mvn archetype:generate \ -DarchetypeGroupId=org.codehaus.mojo.archetypes \ -DarchetypeArtifactId=pom-root \ -DarchetypeVersion=RELEASE
For your sub module try navigating to the directory and running the following.
mvn archetype:generate \ -DarchetypeGroupId=org.apache.maven.archetypes \ -DarchetypeArtifactId=maven-archetype-quickstart \ -DarchetypeVersion=RELEASE
Beiggners sometimes forget what groupId, artifactId, and module correspond to.
groupId: com.everyonealive.planetexpress artifactId gwt-server version 1.0-SNAPSHOT package com.everyonealive.planetexpress module PEGwtServer
Build a Multi Module Project Starting With a pom.xml File
In this case the folder was called gwt-server, the main class was called PEGwtServer and lived in the groupId.
I've also done this by creating the pom.xml first.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <name>BlueGlobe</name> <groupId>com.everyonealive.blueglobe</groupId> <artifactId>blueglobe</artifactId> <packaging>pom</packaging> <version>1.0-SNAPSHOT</version> <description>John's web crawling application</description> </project>
Then run this from the dir with the pom in it
mvn archetype:create -DgroupId=com.everyonealive.blueglobe -DartifactId=planet-express mvn archetype:create -DgroupId=com.everyonealive.blueglobe -DartifactId=webapp -DarchetypeArtifactId=maven-archetype-webapp
Tips..
In this command below "jetty:run" is a "goal"
mvn jetty:run
If you dont see a repo in your IDE; try project clean, mvn clean, mvn clean install, right click root folder maven ... update dependencies.