Using Maven with Eclipse
for Web Applications

Russell Bateman
1 Feburary 2011
last update:

Table of Contents

Introduction
Prerequisites
Step by step
Some principles
Safe operations
Basic aspects of a Maven project
Common "goals"
Classpath variable
Finding a JAR in a Maven repository
Using Maven properties
Eclipse project warnings
A walk down Maven lane...
Useful links

Introduction

Sooner or later, everyone must learn Maven. When you look around for software nowdays, places like java.net don't even provide for downloads anymore because it's assumed that your project builds using a tool that can pull anything you need from a repository.

There's a lot more to say here, so this article is emerging in the sense that I'll come back in to add or change stuff over the next few months.

As I'm at the beginning of my now-intimate association with Maven, this article would not be complete without a small rant. When the subdirectory relationships for Java development were set up, a not inconsiderable mess was created. Over the years, Eclipse worked to abbreviate the mess in order to alleviate the developer's burden. And, it didn't have to do this since being an IDE, it already helped navigate what at the command line was a nightmare.

Maven undoes all of this by reintroducing pointless, repetitive hierarchy. I'm looking forward to Eclipse developers integrating Maven more tightly to alleviate this.

Prerequisites

After some random notes on which Maven plug-ins to use with Eclipse, where to get it, etc. you'll find here, you'll find the following step-by-step useful. Pay special attention to the first few steps of "Walk the walk..."

There are a number of tutorials around that can help you set up and use Maven. They work especially well for simple projects, but not for web application projects where they all seem to fail miserably. This might be due to their age, to mistakes, etc., or it might even say more about my lameness than about the tutorials, but I find these instructions the most useful.

These instructions will not, however, get you up and running in a web application using Facelets or even JSF. For that, you need to know the JAR dependencies. Get those wrong, and your project is little more than mush.

Step by step

As noted, this assumes you've set up the following—in order. If you're missing anything, go to the link.

  1. Java
  2. Tomcat
  3. Eclipse
  4. Maven

Much of the following are something you'll issue from the command line in Linux and even DOS (Windows). Arguably, Maven swims better from the command line than from inside of Eclipse. That's going to change, I suspect, and my perception is also partly due to inexperience. However, many Maven users tell me they do stuff from the command line rather than from Eclipse.

Each time you invoke Maven from the command line (or, if from Eclipse, in the Console view), you'll see a huge number of barely understandable status lines go by. Over time, you'll come to understand what they mean, but at first, they're rather bewildering.

The thing to look for are lines that say failure that do not next go on to try something else as a solution. When you see "BUILD FAILED", you are in trouble. What happens if that occurs during these exercises? It's not likely if you've set up your toolstack (Java and Maven) correctly. And Maven excels at setting up a stub project from scratch. However, if it's unable to reach its repository(ies) over the Internet, you'll see that. If you don't have certain things set up (such as are mentioned on that notes page for Maven above), this will be the result.

I would suggest that if something goes awry, you do not try to import the Eclipse project. Wait until you get no failures (which will probably be right off) and what's inside looks good. That assumes you already know what you're doing in Eclipse Web Tools Platform. But, be prepared for some substantial differences.


  1. Create new project stub. This doesn't have to be done anywhere specific. Remember, you'll be importing this project into Eclipse, but you'll probably want to place this project in an appropriate location for development. In my case, that's usually going to be a Subversion-controlled location, so I'm not doing this on /tmp because it's important where it goes—just not important to Eclipse where it lives.
    mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp \ -DgroupId=package-name -DartifactId=project-name
  2.  
  3. Edit pom.xml to add dependencies and plugins to be used. For doing serious web-application development, this is the real trick: you've got to get just the right set to make JSP, JSF, Facelets, etc. work. You can also just use a larger framework such as Seam or Spring, in which case, either this bit will already be done for you or, at very least, they'll tell you what to put in here.

    Actually, if you set up m2eclipse, you can get prefabricated archetypes that do various such things and write the pom.xml for you. I haven't always been happy or successful with that, and you have to know just what you want based on a name. It's part of the Maven integration with Eclipse, which is not really the object here.

    <dependency> <groupId>org.apache.myfaces.core</groupId> <artifactId>myfaces-api</artifactId> <version>1.2.2</version> </dependency> <dependency> <groupId>org.apache.myfaces.tomahawk</groupId> <artifactId>tomahawk</artifactId> <version>1.1.9</version> </dependency> <dependency> <groupId>org.apache.myfaces.core</groupId> <artifactId>myfaces-impl</artifactId> <version>1.2.2</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>taglibs</groupId> <artifactId>standard</artifactId> <version>1.1.2</version> </dependency> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-servlet_2.5_spec</artifactId> <version>1.2</version> <scope>provided</scope> </dependency> ... <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <!-- if this is how you wish to deploy it... --> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <configuration> <url>http://192.168.1.7:8080/manager</url> <server>mytomcat</server> <path>/mywebapp</path> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-eclipse-plugin</artifactId> <configuration> <wtpapplicationxml>true</wtpapplicationxml> <wtpversion>1.5</wtpversion> <downloadSources>true</downloadSources> <downloadJavadocs>true</downloadJavadocs> <classpathContainers> <classpathContainer>org.eclipse.jst.j2ee.internal.web.container</classpathContainer> <classpathContainer>org.eclipse.jst.j2ee.internal.module.container</classpathContainer> </classpathContainers> <additionalProjectFacets> <jst.web>2.5</jst.web> <jst.jsf>1.2</jst.jsf> </additionalProjectFacets> </configuration> </plugin> </plugins>
  4.  
  5. Create the Java code folder. This is a task that's inexplicably missing from the maven-archetype-webapp goal in the first place. If you don't do this, you may be quite frustrated later when you add your first source code (Java) package. First, you won't know where to do it. Second, you'll do it in the usual place (if you're develop using the Eclipse Dynamic Web Project) and realize that you did it in the wrong place. Do it here and now before setting up the Eclipse project (next step).
    cd project-name mkdir src/main/java
  6.  
  7. Use Maven to create an Eclipse project:
    mvn eclipse:clean eclipse:eclipse
  8.  
  9. Import the new project into Eclipse using File -> Import -> General -> Existing Projects into Workspace. You might not want to copy the project sources into the workspace. There's an option to do that. I resist this because a) I might be updating and committing this project via Subversion and b) I might want to continue to do work on it from the command line via Maven.
  10.  
  11. Begin modifying the various support files appropriately:
    src/main/webapp/WEB-INF/web.xml src/main/webapp/WEB-INF/faces-config.xml

    and adding JSPs, xHTMLs, etc.:

    src/main/webapp/index.jsp src/main/webapp/inputname.jsp
  12.  
  13. Add Java code, in particular, the backing bean(s) for the JSPs/JSFs above.
  14.  
  15. When done, deploy thus:
    mvn tomcat:deploy

Some principles

Safe operations

Any time you think something's gone south between Maven and Eclipse, you can do this:

mvn eclipse:clean eclipse:eclipse

...followed by a refresh of your Eclipse project (select the project, then press F5).

Basic aspects of a Maven project

When you create a new project, there are different aspects that you tell Maven about. These include:

<groupId> the Java package
<artifactId> the project name
<package> default package name in project
<baseDir> filesystem root of project

Common "goals"

mvn test runs project testcases
mvn clean removes the target subdirectory (will be rebuilt from scratch)
mvn package builds the "artifact" or, in Java, the JAR/WAR/etc.
mvn eclipse:eclipse creates a .project file to make an Eclipse project of the project
mvn eclipse:clean

In the above, "eclipse" on the left side of the colon means "use the Maven 2 Eclipse plug-in". The one on the right side means "execute the explicit target in that plug-in".

Classpath variable

Add M2_REPO in Eclipse (Preferences -> Java -> Build Path -> Classpath Variables) as /home/russ/.m2/repository.

Finding a JAR in a Maven repository

Consider http://mirrors.ibiblio.org/, a collection of collections hosting a range of publicly available open source software, in particular, JAR repositories at http://mirrors.ibiblio.org/pub/mirrors/maven2. This is the place to go to find dependencies.

The easiest way is to Google "ibiblio JAR-name" plus any more information that might narrow the search down. This should get you in the vicinity. Look for an ibiblio entry. You may need to adjust the path to see what versions are available. Choose one. There, you'll find subdirectories with version numbers; you choose one (the latest?). You may find there a pom file containing the relevant groupId, artifactId and the version for building the dependency.

For example, let's say I'm looking for myfaces-api-xxx.jar and its matching companion, myfaces-impl-xxx.jar, but don't know where to get it. I do know that it's the Apache one I want.

I look down the list. When I reach the sixth one, I see something close to what I want, myfaces-api-1.2.5. So I go there, but then I truncate the URL to http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/myfaces/core/myfaces-api so that I can examine what versions are in fact available.

Now I can decide which version to choose. Obviously, Maven will not help you do that. The pom file available with the JARs has no extension (which fact is helpful for if you download it, it won't risk being confused as a real one in your build). This file is the pom.xml used to construct the JARs you're looking at. In addition, for this JAR set at least, I see I've got not only the library JAR itself, myfaces-api-1.2.8.jar, but also source and Javadoc JARs that will be useful to me as I edit my code in Eclipse (content assist and documentation).

Using Maven properties to clean up pom.xml

This allows for versions to appear in a single place (near the top of pom.xml?).

<properties> <spring-version>2.5.5</spring-version> <junit-version>4.5</junit-version> <commons-dbcp-version>1.2.2</commons-dbcp-version> <commons-logging-version>1.1.1</commons-logging-version> </properties>

Later, you just specify a dependency thus:

<dependency> <groupId>commons-logging<groupId> <artifactId>commons-logging</artifactId> <version>${commons-logging-version}</version> </dependency>

Eclipse project warnings

It appears inevitable that Eclipse will issue warnings, at least for web-applications projects.

A walk down Maven lane...

Now that we've begun seriously to grok Maven, let's take a simple walk down the process of creating a new Eclipse project. This is a project that I started out using

mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=com.one -DartifactId=one

I began my fresh build in order to illustrate this walk by deleting everything underneath ~/.m2/repository so it would have to start over from scratch. For brevity, I've removed the redundant "Downloading: ..." statements since they are identical to the subsequent, successful "Downloaded: ..." ones. There were no warnings or errors.

This is Maven downloading all of the plug-ins it wants. Mostly, Maven decides which ones to download.

russ@russ-elite-book:~/dev/maven-tutorial/one> mvn eclipse:clean eclipse:eclipse [INFO] Scanning for projects... Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom (5 KB at 4.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom (13 KB at 20.9 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/16/maven-parent-16.pom (23 KB at 37.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/apache/7/apache-7.pom (15 KB at 22.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar (23 KB at 58.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.3.1/maven-install-plugin-2.3.1.pom (5 KB at 5.6 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-install-plugin/2.3.1/maven-install-plugin-2.3.1.jar (23 KB at 22.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.4.3/maven-resources-plugin-2.4.3.pom (6 KB at 7.9 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.4.3/maven-resources-plugin-2.4.3.jar (24 KB at 25.6 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.7.1/maven-surefire-plugin-2.7.1.pom (10 KB at 11.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire/2.7.1/surefire-2.7.1.pom (10 KB at 10.1 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/18/maven-parent-18.pom (24 KB at 22.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/apache/8/apache-8.pom (14 KB at 16.1 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/2.7.1/maven-surefire-plugin-2.7.1.jar (29 KB at 28.6 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/2.0.2/maven-compiler-plugin-2.0.2.pom (3 KB at 3.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins/8/maven-plugins-8.pom (6 KB at 7.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/5/maven-parent-5.pom (15 KB at 16.9 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/apache/3/apache-3.pom (4 KB at 3.9 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-compiler-plugin/2.0.2/maven-compiler-plugin-2.0.2.jar (18 KB at 15.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-war-plugin/2.1.1/maven-war-plugin-2.1.1.pom (7 KB at 7.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-war-plugin/2.1.1/maven-war-plugin-2.1.1.jar (76 KB at 65.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.5/maven-deploy-plugin-2.5.pom (6 KB at 6.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins/16/maven-plugins-16.pom (13 KB at 14.3 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/15/maven-parent-15.pom (24 KB at 25.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/apache/6/apache-6.pom (13 KB at 14.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-deploy-plugin/2.5/maven-deploy-plugin-2.5.jar (23 KB at 21.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-site-plugin/2.0.1/maven-site-plugin-2.0.1.pom (14 KB at 15.3 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins/13/maven-plugins-13.pom (12 KB at 13.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/11/maven-parent-11.pom (32 KB at 33.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/apache/5/apache-5.pom (5 KB at 4.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-site-plugin/2.0.1/maven-site-plugin-2.0.1.jar (79 KB at 69.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-antrun-plugin/1.3/maven-antrun-plugin-1.3.pom (5 KB at 5.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-plugins/12/maven-plugins-12.pom (12 KB at 6.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/9/maven-parent-9.pom (33 KB at 54.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/apache/4/apache-4.pom (5 KB at 5.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-antrun-plugin/1.3/maven-antrun-plugin-1.3.jar (24 KB at 51.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.pom (15 KB at 16.9 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-5/maven-assembly-plugin-2.2-beta-5.jar (204 KB at 159.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.1/maven-dependency-plugin-2.1.pom (8 KB at 10.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-dependency-plugin/2.1/maven-dependency-plugin-2.1.jar (104 KB at 87.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.0/maven-release-plugin-2.0.pom (8 KB at 10.1 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/release/maven-release/2.0/maven-release-2.0.pom (7 KB at 7.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-release-plugin/2.0/maven-release-plugin-2.0.jar (38 KB at 36.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/2.4/maven-eclipse-plugin-2.4.pom (6 KB at 6.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-eclipse-plugin/2.4/maven-eclipse-plugin-2.4.jar (126 KB at 108.3 KB/sec)

These appear to be some important POMs Maven wants access to. Just as the section above, it's Maven and not my project that's causing this.

[INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building one Maven Webapp 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-eclipse-plugin:2.4:clean (default-cli) @ one --- Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-archiver/1.0-alpha-7/plexus-archiver-1.0-alpha-7.pom (2 KB at 1.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-components/1.1.6/plexus-components-1.1.6.pom (2 KB at 2.3 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus/1.0.8/plexus-1.0.8.pom (8 KB at 8.1 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.2/plexus-utils-1.2.pom (767 B at 1.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus/1.0.5/plexus-1.0.5.pom (6 KB at 6.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-container-default/1.0-alpha-8/plexus-container-default-1.0-alpha-8.pom (8 KB at 7.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.pom (7 KB at 7.6 KB/sec) Downloaded: http://repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.pom (998 B at 1.2 KB/sec) Downloaded: http://repo1.maven.org/maven2/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.pom (4 KB at 3.9 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-project/2.0.6/maven-project-2.0.6.pom (3 KB at 3.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven/2.0.6/maven-2.0.6.pom (9 KB at 10.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-settings/2.0.6/maven-settings-2.0.6.pom (2 KB at 2.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-model/2.0.6/maven-model-2.0.6.pom (3 KB at 3.9 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.4.1/plexus-utils-1.4.1.pom (2 KB at 2.3 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus/1.0.11/plexus-1.0.11.pom (9 KB at 9.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-container-default/1.0-alpha-9-stable-1/plexus-container-default-1.0-alpha-9-stable-1.pom (4 KB at 4.9 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-containers/1.0.3/plexus-containers-1.0.3.pom (492 B at 0.6 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus/1.0.4/plexus-1.0.4.pom (6 KB at 6.2 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-profile/2.0.6/maven-profile-2.0.6.pom (2 KB at 2.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-artifact-manager/2.0.6/maven-artifact-manager-2.0.6.pom (3 KB at 3.3 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-repository-metadata/2.0.6/maven-repository-metadata-2.0.6.pom (2 KB at 2.3 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-artifact/2.0.6/maven-artifact-2.0.6.pom (2 KB at 2.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-registry/2.0.6/maven-plugin-registry-2.0.6.pom (2 KB at 2.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-api-2.0.6.pom (2 KB at 2.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.4.2/plexus-utils-1.4.2.pom (2 KB at 2.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-interactivity-jline/1.0-alpha-5/plexus-interactivity-jline-1.0-alpha-5.pom (772 B at 1.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-interactivity/1.0-alpha-5/plexus-interactivity-1.0-alpha-5.pom (482 B at 0.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-components/1.1.4/plexus-components-1.1.4.pom (3 KB at 2.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/jline/jline/0.9.1/jline-0.9.1.pom (145 B at 0.2 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-5/plexus-interactivity-api-1.0-alpha-5.pom (430 B at 0.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-archiver/2.2/maven-archiver-2.2.pom (2 KB at 1.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/shared/maven-shared-components/3/maven-shared-components-3.pom (2 KB at 2.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-parent/4/maven-parent-4.pom (10 KB at 10.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-project/2.0/maven-project-2.0.pom (2 KB at 2.1 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven/2.0/maven-2.0.pom (9 KB at 9.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-profile/2.0/maven-profile-2.0.pom (2 KB at 1.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-model/2.0/maven-model-2.0.pom (3 KB at 3.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-artifact-manager/2.0/maven-artifact-manager-2.0.pom (2 KB at 1.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-repository-metadata/2.0/maven-repository-metadata-2.0.pom (2 KB at 1.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-artifact/2.0/maven-artifact-2.0.pom (723 B at 0.9 KB/sec) Downloaded: http://repo1.maven.org/maven2/biz/aQute/bndlib/0.0.145/bndlib-0.0.145.pom (886 B at 1.2 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-archiver/1.0-alpha-7/plexus-archiver-1.0-alpha-7.jar (139 KB at 66.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-5/plexus-interactivity-api-1.0-alpha-5.jar (14 KB at 12.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar (119 KB at 36.9 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/maven/maven-archiver/2.2/maven-archiver-2.2.jar (10 KB at 9.2 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-utils/1.4.2/plexus-utils-1.4.2.jar (186 KB at 41.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/jline/jline/0.9.1/jline-0.9.1.jar (46 KB at 9.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-interactivity-jline/1.0-alpha-5/plexus-interactivity-jline-1.0-alpha-5.jar (6 KB at 1.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/biz/aQute/bndlib/0.0.145/bndlib-0.0.145.jar (112 KB at 38.2 KB/sec)

Because my project was already an Eclipse project, the eclipse:clean part forces Maven to wipe the old Eclipsifying bits and re-do them.

[INFO] Deleting file: .project [INFO] Deleting file: .classpath [INFO] Deleting file: .wtpmodules [INFO] Deleting file: .component [INFO] Deleting file: org.eclipse.wst.common.component [INFO] Deleting file: org.eclipse.wst.common.project.facet.core.xml [INFO] Deleting file: org.eclipse.jdt.core.prefs [INFO] Deleting directory: .settings [INFO] [INFO] >>> maven-eclipse-plugin:2.4:eclipse (default-cli) @ one >>> [INFO] [INFO] <<< maven-eclipse-plugin:2.4:eclipse (default-cli) @ one <<< [INFO] [INFO] --- maven-eclipse-plugin:2.4:eclipse (default-cli) @ one --- [INFO] Adding support for WTP version 1.5.

Okay, now let's have some fun: this is the stuff we've indicated as important to our project via our own pom.xml and Maven is going out to the repositories it knows about to get it. We have specified NO repositories via any elements ourselves, which is best practice as long as Maven is able to find what we need.

First, Maven goes to get all the POMs that describe our consumables. This enables Maven to assess dependencies that we would not necessarily know about—that commons-beanutils depends on a POM in commons-parent. Though it doesn't, that POM might have told of some physical dependencies (JARs). That way, we don't have to have an exhaustive list; we just know about the main dependencies that interest us.

Downloaded: http://repo1.maven.org/maven2/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.pom (11 KB at 14.1 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/commons/commons-parent/14/commons-parent-14.pom (31 KB at 74.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom (18 KB at 40.6 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/commons/commons-parent/5/commons-parent-5.pom (16 KB at 17.6 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-codec/commons-codec/1.4/commons-codec-1.4.pom (11 KB at 12.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/commons/commons-parent/11/commons-parent-11.pom (25 KB at 25.6 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.pom (13 KB at 7.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/commons/commons-parent/9/commons-parent-9.pom (22 KB at 35.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-digester/commons-digester/2.1/commons-digester-2.1.pom (11 KB at 17.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/commons/commons-parent/17/commons-parent-17.pom (31 KB at 50.3 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-discovery/commons-discovery/0.4/commons-discovery-0.4.pom (6 KB at 6.2 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.pom (6 KB at 6.3 KB/sec) Downloaded: http://repo1.maven.org/maven2/javax/servlet/jstl/1.2/jstl-1.2.pom (356 B at 0.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/myfaces/core/myfaces-api/1.2.8/myfaces-api-1.2.8.pom (14 KB at 21.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/myfaces/core/myfaces-core-project/1.2.8/myfaces-core-project-1.2.8.pom (6 KB at 7.1 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/myfaces/myfaces/6/myfaces-6.pom (30 KB at 47.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/myfaces/core/myfaces-impl/1.2.8/myfaces-impl-1.2.8.pom (29 KB at 45.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-collections/commons-collections/3.2/commons-collections-3.2.pom (11 KB at 13.6 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-codec/commons-codec/1.3/commons-codec-1.3.pom (6 KB at 8.0 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-beanutils/commons-beanutils/1.7.0/commons-beanutils-1.7.0.pom (357 B at 0.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-digester/commons-digester/1.8/commons-digester-1.8.pom (7 KB at 8.4 KB/sec)

At long last, Maven goes to get all the JARs on which our project is dependent...

Downloaded: http://repo1.maven.org/maven2/commons-beanutils/commons-beanutils/1.8.3/commons-beanutils-1.8.3.jar (227 KB at 325.1 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar (60 KB at 51.4 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-codec/commons-codec/1.4/commons-codec-1.4.jar (57 KB at 49.8 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar (562 KB at 247.1 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-digester/commons-digester/2.1/commons-digester-2.1.jar (193 KB at 302.1 KB/sec) Downloaded: http://repo1.maven.org/maven2/commons-discovery/commons-discovery/0.4/commons-discovery-0.4.jar (75 KB at 65.7 KB/sec) Downloaded: http://repo1.maven.org/maven2/javax/servlet/jstl/1.2/jstl-1.2.jar (405 KB at 274.3 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/myfaces/core/myfaces-api/1.2.8/myfaces-api-1.2.8.jar (371 KB at 253.5 KB/sec) Downloaded: http://repo1.maven.org/maven2/org/apache/myfaces/core/myfaces-impl/1.2.8/myfaces-impl-1.2.8.jar (782 KB at 427.1 KB/sec) [INFO] Using source status cache: /home/russ/dev/maven-tutorial/one/target/mvn-eclipse-cache.properties [INFO] Wrote settings to /home/russ/dev/maven-tutorial/one/.settings/org.eclipse.jdt.core.prefs [INFO] Wrote Eclipse project for "one" to /home/russ/dev/maven-tutorial/one. [INFO] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1:48.383s [INFO] Finished at: Fri Feb 04 16:53:04 MST 2011 [INFO] Final Memory: 7M/118M [INFO] ------------------------------------------------------------------------

Appendix: Some useful links

Link to Maven installation instructions and getting started.


Other useful Maven links.


As I say, I'm not very happy with many of these, but even broken, these tutorials and others here, brought me as far as I am.