This really clears things up--many thanks!
-- Dhruva B. Reddy Senior Associate of Technology, Level 2 | Sapient 25 1st Street Cambridge, MA, 02141, USA desk: +1 617 452 1900 fax: +1 617 621 1300 www.sapient.com -----Original Message----- From: John Casey [mailto:[EMAIL PROTECTED] Sent: Thursday, 07 February 2008 17:01 To: Maven Users List Subject: Re: Maven Concepts You've got it exactly right. Maven builds are usually oriented around the concept of a lifecycle, which consists of phases in a specific order. Each phase has zero or more mojos (usually called goals) bound to it. Each phase in the lifecycle implies all of the phases that come before it. This allows users to bind (or configure) different goals to different phases of the build, then the standard phase names to run the build. The default goals for a given type of project are also bound to the lifecycle in this way, but behind the scenes, such that the user can supplement these default goals using configurations in the pom.xml. So, if you have a jar project (<packaging>jar</packaging>), you might have something like this: Phase Goals -------- ----------- validate (none) initialize (none) ... compile org.apache.maven.plugins:maven-compiler- plugin:compile ... test org.apache.maven.plugins:maven-surefire- plugin:test ... package org.apache.maven.plugins:maven-jar-plugin:jar ... install org.apache.maven.plugins:maven-install- plugin:install ... etc. Now, if you just want to compile your project, you simply call the 'compile' phase, like this: mvn compile If you want to run the unit tests, call this: mvn test Note that in order to run unit tests, you must have compiled your project's main sources. That's handled here, since the test phase is later in the lifecycle than the compile phase...'test' implies 'compile' and all the other phases (in order) that come before 'test'. On the other hand, Maven also supports certain one-off goals that are usually meant to help manage the project build in certain special cases, or give information about the build. One such example gives you a glimpse of the POM after all inheritance and profile injection has been completed: mvn help:effective-pom which is shorthand for: mvn org.apache.maven.plugins:maven-help-plugin:effective-pom Hope that helps, -john On Feb 7, 2008, at 4:50 PM, Dhruva Reddy wrote: > I know this seems like a silly thing to post on here, but... > > What exactly is a goal and what is a phase? I can't find a good > answer in the documentation and there's a lot of seemingly > conflicting information out there. > > My current understanding is that a phase is a part of a lifecycle > (process-resources, compile, etc). A goal is somewhat analogous to > an ANT-task, but with a focus on what should happen, rather than > how it is done. > > Can someone clear this up for me, giving examples? > > Thanks, > Dhruva --- John Casey Committer and PMC Member, Apache Maven mail: jdcasey at commonjava dot org blog: http://www.ejlife.net/blogs/john rss: http://feeds.feedburner.com/ejlife/john --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
