It is also recommended to use an IDE that directly supports Maven. We use Spring Source ToolSuite (a variant of Eclipse with built-in Maven support) as well as a “pure” Eclipse (Helios – 3.6.2) with a Maven plugin applied.
- Install Maven Support in Eclipse
If your development environment does not have Maven built into it already, it will need to be added. The following details how to install Maven on an install of Eclipse that doesn’t already have Maven support.
- On the menu bar of Eclipse, click on Help -> Install new Software…
- A dialog should appear titled “Install”.
You will need to add a software site to obtain the Maven plugin from.
Click on the “Add…” button at the top right of this dialog. - A sub-dialog should appear titled “Add Repository”.
In the field marked “Name:” enter: Maven
In the field marked “Location:” enter: http://download.eclipse.org/technology/m2e/updates/N/
Click “OK” and this sub-dialog will be dismissed. - After a short delay the list in the middle of the “Install” dialog will contain an entry titled “Maven Integration for Eclipse”.
Tick the box next to it.
Then click “Next > ” at the bottom of the dialog. - A progress bar will appear on the bottom of this dialog. This seems to take quite a while to resolve (approximately 5 minutes on our test machine). Please wait for this to complete. On completion, the “Next >” button will become enabled so please click it.
- You now have an opportunity to review the License for this software. If you are happy with these terms, select the radio button “I accept the terms of the license agreement” and click “Finish”.
- Eclipse will now install the software. The progress can be seen by looking at the “Progress” view. Once complete, Eclipse will need to be restarted.
- Once Eclipse has restarted, Maven will have been installed.
- Configuring Maven
Your Maven settings file needs to be configured so that Maven can communicate with the Metadata Technologies Nexus repository. The settings file can be found within your home directory.
On Windows NT the default home directory is: C:\Documents and Settings\<username>
On Windows 7 the default home directory is: C:\Users\<username>
Within this directory there will be a directory called “.m2″. Since this directory is prefixed with a dot, it is sometimes hidden from the default view. You need to navigate to the .m2 directory and within it there should be a file named “settings.xml”. This is the Maven settings file which will need to be modified in the following manner:
Adding a server entry
Since the Metadata Technology repository is password protected you will need to add a “server” entry and supply a username and password. If you do not have the username and password for the Metadata Technology repository, then please contact us so that we can supply it.Here is an example of a server entry (note that the username and password are invalid):
<servers> <server> <id>nexus</id> <username>userid</username> <password>password</password> </server> </servers>Specifying the Repository
The repository to download the components from must be specified. The URL of the repository is: http://www.metadatatechnology.com:8081/nexus/content/repositories/metatechAn example repository looks like:
<repository> <id>nexus</id> <url>http://www.metadatatechnology.com:8081/nexus/content/repositories/metatech</url> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository>Here is an example of a complete Maven settings file (you can download the file from here ):
<settings> <servers> <server> <id>nexus</id> <username>userid</username> <password>password</password> </server> </servers> <profiles> <profile> <id>dev</id> <repositories> <repository> <id>nexus</id> <url>http://www.metadatatechnology.com:8081/nexus/content/repositories/metatech</url> <snapshots> <enabled>true</enabled> </snapshots> <releases> <enabled>true</enabled> </releases> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles> </settings>More information about the Maven settings file can be found at: http://maven.apache.org/settings.html
- Setting the Eclipse Workspace to use Maven
The Eclipse workspace must be setup correctly to read values from your Maven settings file. Often this has been set automatically by the Maven install. To check that the values are correct, follow these instructions:
- On Eclipse’s main menu bar, select “Window” and then “Preferences”.
The preferences dialog should now be displayed. - In the list on the left-hand side, select Maven and the sub-entry “User Settings”.
The area on the right hand side should show the User Settings. - In the User Settings area, the topmost text entry field should state the full path of the Maven XML settings file. This value will be something like {user home directory}\.m2\{maven settings file}. For example on Windows 7, for the user Adam with a settings file of settings.xml could have: C:\Users\Adam\.m2\settings.xml.
To check that the value is set correctly, you can open the file through the “open file” link and check that the file is as expected. If you make changes to your Maven settings file, you must return to this screen and click “Update Settings” for the changes to take effect.
- On Eclipse’s main menu bar, select “Window” and then “Preferences”.
- Setting up an Eclipse project to use Maven
Your projects within Eclipse will require Maven capabilities. You can either convert an existing project to a Maven project or you can create a new Maven project.
Converting an Existing Project
To convert an existing project to a Maven project, select the project in the Explorer window and click the right mouse button. In the popup-window now displayed, choose “Configure”, and then “Convert To Maven project”. A dialog will appear entitled “Create a new POM”. In this dialog you should enter the details for the POM file for the project. You will need to specify a Group Id and Artefact id. These can be any value and will be used to identify your project. If you’re not too concerned with distributing your project to others, then put in any values (such as “com.test” and “test”) to complete this stage. These values can be modified later. Other values on this screen are optional. Once you are satisfied with your values, click “Finish” to complete the modifications to the project.Creating a new Maven Project.
To create a new Maven project, from Eclipse’s main menu bar, select “File”, then “New” and then “Project…”. A dialog will be displayed with the title “New Project”. Expand the Maven folder and select “Maven Project”. Then click “Next >”The dialog will re-title to “New Maven Project”. It is easiest to select “Create a simple project”. Then click “Next >”.
You will need to specify a Group Id and Artefact id. These can be any value and will be used to identify your project. If you’re not too concerned with distributing your project to others, then put in any values (such as “com.test” and “test”) to complete this stage. These values can be modified later. Other values on this screen are optional. Once you are satisfied with your values, click “Finish” to create the project.
- Adding dependencies to the Eclipse project
Once you have an Eclipse project with Maven support, you will notice that there is a file called “pom.xml” at the root level of the project. This is the file where you will specify the dependencies on the Fusion Components.
If you open this file, Eclipse’s default behaviour is to open an editor window displaying the contents of the POM in a graphical manner. Tabs at the bottom of this window will allow you to view various aspects of the POM, or you can look at the raw POM file.
To add a dependency, select the “Dependencies” tab and the editor window will show all of the dependencies on this project.
Select “Add…” and a new dialog is displayed titled “Select Dependency”. Here you will need to specify the values for the dependencies. You must specify the Group Id, the Artifact Id and Version for each dependency. You can search for dependencies that exist already within your Maven repository (dependencies that have already been downloaded to your machine), but when adding a new dependency for the first time you must specify the values.
The Group Id for all of the Fusion components is “com.metadatatechnology”
The Artifact Id will be the dependency that you want e.g. SdmxApi
The Version will be the version of the component e.g. “3.0”
