Maven
If not already done so, obtain a local install of Maven for your development environment. For instructions on how to install and build maven please refer to the documentation posted at Requirements. If all goes well, you should be able to open a command prompt window, and at the command prompt, type 'mvn -version'.
mvn -version
You should see a message similar to below, displaying the version of Maven and Java.
Apache Maven 2.2.1 (r801777; 2009-08-06 14:16:01-0500) Java version: 1.6.0_22 Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home Default locale: en_US, platform encoding: MacRoman OS name: "mac os x" version: "10.6.6" arch: "x86_64" Family: "mac"
Depending on you comfort level there may be more Maven configuration tricks that you may want to perform, such as customizing your settings.xml file. Look at the Additional References section below for more tutorials on Maven configurations that you may find helpful.
Creating the Maven Project in Eclipse
There are probably various ways to create a maven project but I found this one very simple at creating a basic maven structured project using archetypes based on a tutorial that was found at http://www.avajava.com/tutorials/categories/maven
Step 1. Create an external tool configuration
1. Go to 'Run' -> 'External Tools' -> 'External Tools Configuration' (see below)
2. Create a new program. Right-click on 'Program' and select 'New'
3. Create the archetype~create project according to the image below.
Name: the name of your new archetype which we labeled 'mvn archetype~create'
Location: the location of the maven executable (/usr/bin/mvn)
Working Directory: the Eclipse workspace folder
Arguments: the string_prompt argument means that a pop-up will display asking for the groupId and artifactId
After you click on 'Apply' the newly created program will appear under the 'Program' list.
Step 2. Run the new Archetype you created
1. Click on the new archetype you created
Step 3. Fill out the prompts
1. Enter the groupid such as 'edu.youruniversity'
2. Enter the artifactid, which is the name of your new portlet, such as 'TestPortlet'
Step 4. Importing the new project into Eclipse
The above steps created the project inside your Eclipse workspace folder but as you noticed you don't see it in your Package Explorer, so we need to add the project.
- Click 'File' -> 'New' -> 'Java Project'
- Enter the Name of your new project. As you can see, as you type in the name the Location will automatically point to the workspace project that you created above.