Here is short instruction how to incorporate Maven into existing Eclipse projects from scratch, step by step. The goal of Maven introduction presented here is quite generic, however I installed Maven to manage dependencies (jars). Maven build, installs or clean functions are not used by me. If You need to know more about maven itself – this screencast is good start.
1. Install eclipse plugin for maven
I recommend m2eclipse as it is most popular and works quite well. It is supported by Eclipse: 3.6 Galileo and 3.7 Indigo. Install it by ‘Install new software‘ Eclipse option. Update site link you will find on this site.
This will install its own Maven instance, so you don’t need to install Maven yourself – m2eclipse will handle it. However manual Maven installation is necessary if You need another version that is provided in m2eclipse by default.
2. Update existing project with maven functionality
(If You are creating new project use Eclipse -> New Project and choose type: Maven. Params to enter are the same as described below)
To create pom.xml file and tell to m2eclipse to use this file:
Right click on project -> configure -> Convert to maven project
On the project configuration dialog You need to fill in these fields:
- groupId – in fact this is main package name that is used in eclipse project. Param states that project belongs to some group, pointed by package name.
- artifactId – project name that is used in Eclipse. This will be the name of the file that will be produced by Maven after compilation (e.g. name of external jar)
- archetype – project type. This is similar to creating new project in Eclipse, where You choose on of the project types at the beginning (Android project / Java project / Dynamic Web Project etc.). Like Eclipse project types, Maven provides its archetypes. Choosing proper one, eases project configuration. Maven preconfigures its structure and pom.xml file.
- dependencies – list of all jars or another workspace projects required for Mavenized project to run. Referenced workspace projects should also be maven ones.
3. Updating Maven project configuration
After making changes in Maven config (pom.xml file) you will have to update project configuration to reflect these changes in project.
Do it by:
Right Click on th project -> Maven -> Update project configuration
4. That’s all
On another computer, where this project is used it is enough to install m2eclipse (point 1.) and trigger ‘Update Project Configuration’ (point 3.).
Did I help you?
I manage this blog and share my knowledge for free sacrificing my time. If you appreciate it and find this information helpful, please consider making a donation in order to keep this page alive and improve quality