Apache Maven notes
(tested with Maven 3.0.4, POM 4.0.0)
- http://maven.apache.org/guides/getting-started/
- http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart # -DarchetypeVersion=5-SNAPSHOT
mvn help:effective-pom
mvn clean install
mvn package
via the maven assembly plugin
Add to pom/xml
:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.package.name.of.your.main.class</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
To assemble:
mvn clean compile assembly:single
(tested with Eclipse Juno 4.2)
m2eclipse plugin for Eclipse
(tested with org.eclipse.m2e.feature 1.3.0.20130129-0926)
Eclipse -> Project Explorer -> project context menu -> Configure -> Convert to Maven Project
Make sure your pom.xml
specifies the right directory for source code to prevent "Cannot nest '...' inside library 'Project/src" errors:
<project ...>
...
<build>
<sourceDirectory>src/main/java</sourceDirectory>
...
Eclipse -> Project Explorer -> project context menu -> Maven -> Update Project...
Manually via maven-eclipse-plugin for Maven
Before importing into Eclipse:
mvn eclipse:eclipse
In case of errors:
mvn eclipse:clean