Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

...

a New Maven Project
  1. Click 'File' -> '

...

  1. New' -> '

...

      Image Removed

     2. Create a new program. Right-click on 'Program'  and select 'New'

      Image Removed

     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.

      Image Removed

Step 2. Run the new Archetype you created

     1. Click on the new archetype you created 

      Image Removed

Step 3. Fill out the prompts

     1. Enter the groupid such as 'edu.youruniversity' 

      Image Removed

     2. Enter the artifactid, which is the name of your new portlet, such as 'TestPortlet'

      Image Removed

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.

  1. Click 'File' -> 'New' -> 'Java Project'
  2. 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. Click 'Finish'

      Image Removed

Step 5. Your New Project

After Step 4, you will see your newly created Maven project in the package explorer with the following maven structure, but you'll see errors because we are missing some dependencies.

      Image Removed

To fix the dependency problem, create another External Tools Program 

  1. Go to 'Run' -> 'External Tools' -> 'External Tools Configuration'
  2. Then, Right-click on 'Program'  and select 'New'
  3. Create a new archetype called 'mvn eclipse~eclipse' with the following information:
    1. Name: mvn eclipse~eclipse
    2. Location: /usr/bin/mvn 
    3. Working Directory:  You'll need to enter the location of your project '${project_loc}'  
    4. Arguments: eclipse:eclipse  -DdownloadSources=true  -DdownloadJavadocs=true
  4. Click 'Apply' when you are finished. Now, in your Program list you'll have a new archetype called 'mvn eclipse~eclipse'

Now, resolve the dependencies by highlighting your 'TestPortlet' pom.xml file and then run your new mvn eclipse~eclipse archetype.

      Image Removed

After, running the 'mvn eclipse~eclipse' archetype refresh your new project by right-clicking your project and select 'Refresh'. Your errors should now be gone.

Below you will see that after you executed the eclipse:eclipse command the Referenced Libraries were created. 

      Image Removed

...

  1. Other' -> 'Maven Project' and then click 'Next'.

Image Added

Step 2. Select project name and location.  

Use the default Workspace location or specify the location if necessary. Image Added

 Step 3. Select an archetype

Select the maven-archetype-webapp archetype from the list. It's a simple Maven web structure.

Image Added


Info
iconfalse

   Additional References

...