Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Maven User
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<h1>Getting Started with Maven</h1> <img class="editor-inline-macro" src="/plugins/servlet/confluence/placeholder/macro?definition=e3RvYzptYXhsZXZlbD00fG1pbkxldmVsPTJ8b3V0bGluZT1mYWxzZXx0eXBlPWxpc3R9&locale=en_GB&version=2" data-macro-name="toc" data-macro-parameters="maxlevel=4|minLevel=2|outline=false|type=list"> <h2>General</h2> <p>Although Maven can be used integrated in your favorite IDE, its basic usage is as a commandline tool. So, go download the latest release and install it. To begin using Maven, you have to download and install it.</p> <p>Begin here: <a href="http://maven.apache.org/download.html">http://maven.apache.org/download.html</a></p> <p>I started with Maven 2.0.4. Download the binary distribution that suits your operating system, e.g. tar.gz (linux), or zip (windows). Unzip the contents to directory that is accessible to your user. My installation is at /home/piratepete/maven-2.0.4 .</p> <p>However, we can't use Maven just yet. Maven requires two environement variables: M2_HOME, and JAVA_HOME. M2_HOME refers to the directory where you unpacked your Maven, while JAVA_HOME, refers to your JDK directory.</p> <p>For Unix users: </p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> M2_HOME=/home/piratepete/maven-2.0.4 </pre></td></tr></table> <p>and</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> JAVA_HOME=/home/priatepete/Java/j2sdk1.4.2_12 </pre></td></tr></table> <p>For Windows users:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> M2_HOME=C:\maven-2.0.4 </pre></td></tr></table> <p>and</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> JAVA_HOME=C:\Program Files\Java\j2sdk1.4.2_12 </pre></td></tr></table> <p>Environment variables are handy e.g. if you change things a lot. After you install Maven you'll need to set your PATH to the $M2_HOME/bin directory. Although modifying the PATH environmental variable is not required, it is highly recommended so thatyou can use Maven outside its installation directory.</p> <p>For Unix users: </p> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> PATH=$M2_HOME/bin:$PATH </pre></td></tr></table> <p>For Windows users:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> PATH=%M2_HOME%\bin;%PATH% </pre></td></tr></table> <p>Now open a terminal or cmd window. Type the following and you'll see something like:</p> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> piratepete@piratepete-laptop:~$ mvn --version Maven version: 2.0.4 </pre></td></tr></table> <p>or</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> C:\My Projects> mvn --version Maven version: 2.0.4 </pre></td></tr></table> <h2>Maven for Make and GNU Autotools users</h2> <table class="wysiwyg-macro" data-macro-name="info" data-macro-parameters="title=Please Contribute" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2luZm86dGl0bGU9UGxlYXNlIENvbnRyaWJ1dGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="RICH_TEXT"><tr><td class="wysiwyg-macro-body"> <p>This section is incomplete. If you have experience with Make, Maven, and/or the GNU Autotools, please add any information here that you think might be useful to new Maven users.</p></td></tr></table> <p>Since both <a href="http://maven.apache.org">Maven</a> and the <a href="http://en.wikipedia.org/wiki/GNU_build_system">GNU Autotools </a> are involved with configuring and executing a software build, there is much overlap in their capabilities and the scenarios in which they are used. However, there are also some significant differences. It is hoped that this section will help bridge the conceptual gap between these tools.</p> <p>From this point on, our discussion of Make will be implied by discussion of the GNU Autotools. We do this in part to simplify (in the future we have separate Make and GNU Autotools sections of this page), and in part becuase the conventions used by hand-rolled Makefiles are generally a subset of the requirements documented in the GNU Coding Standards.</p> <p>Over the years a number of conventions have come into widespread use for expected targets and behaviors in Makefiles. The "best practices" in this area are documented in the <a href="http://www.gnu.org/prep/standards/">GNU Coding Standards</a> (in particular, see the <a href="http://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html#Makefile-Conventions">"Makefile Conventions"</a> subsection of <a href="http://www.gnu.org/prep/standards/html_node/Managing-Releases.html#Managing-Releases">"The Release Process"</a> section.</p> <p>In Make, the developer typically supplies (at least) the following targets: <code>all</code>, <code>clean</code>, and <code>install</code>, and often times <code>check</code> (or <code>test</code>), as well.</p> <p>In Maven, the "targets" are really the names of a <a href="http://cvs.peopleware.be/training/maven/maven2/buildLifecyclePhases.html">phase</a> of one of the maven lifecycles. There are three Maven lifecycles: <a href="http://cvs.peopleware.be/training/maven/maven2/buildLifecyclePhases.html#default">default</a>, <a href="http://cvs.peopleware.be/training/maven/maven2/buildLifecyclePhases.html#clean">clean</a>, and <a href="http://cvs.peopleware.be/training/maven/maven2/buildLifecyclePhases.html#site">site</a>.</p> <p>When a user invokes a Make target (or targets), Make uses the timestamps of dependent artifacts to decide which previous targets need to be rebuilt prior to building the requested target(s). In maven, the user invokes a phase name (or names), and Maven runs all previous build phases that belong to the same lifecycle as the invoked phase(s).</p> <p>A typical Make invocation might look like this:</p> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> $ make clean && make all </pre></td></tr></table> <p>A typical Maven-2.x invocation might look like this:</p> <table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> $ mvn clean install </pre></td></tr></table> <p>Users and developers familiar with the conventional Make target <code>install</code> might cringe at that <code>mvn</code> invocation, but the <code>install</code> phase in Maven is not at all like the target by that name typically found in a <code>Makefile</code>. In fact, Maven does not have a build phase that maps to the functionality typically performed by <code>make install</code> (and I have never seen such functionality kludged into a Maven build). This is one of the areas where the intended audiences of the tools diverge; <code>make install</code> is (typically, but not necessarily) intended for sysadmins actually installing software on a system for use by end-users, whereas <code>mvn install</code> is typically done by a developer working in his home directory, and simply copies the current build artifact beneath a special directory (<code>${HOME}/.m2/repsoitory/...</code>) that will be queried by other Maven builds that declare a dependency on the artifact.</p>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced