follow mattconroy at http://twitter.com

Compiling an Apache Maven Project

Compiling a Maven project was pretty darn easy. You simply run the command mvn compile. This command tells maven to compile the source code into classes. The classes end up in the target/classes dir and target/test-classes dir.

Running mvn package will build a jar of the project. The version used in the jar name is contained inside the main level pom.xml.

pom.xml


   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
4.0.0
com.mattconroy.project
TestProject
jar   1.0-SNAPSHOT
TestProject
http://maven.apache.org


junit
junit
3.8.1
test


Notice the tag sets the jar version name.

So what does this buy us? We can now install our built component into a local or remote respository for use in other projects or run the program to do some business logic. Obviously we are far from having a complete product since we are missing libraries and other meta data needed to have a easily maintainable project, but this gives us a template to build off of.

Leave a Reply

Spam protection by WP Captcha-Free