Steps to enable the Maven integration with eclipse - java

I have installed maven and eclipse juno, on CentOS. Can anyone guide me how to integrate Eclipse with maven. I am going to use this configuration for Mahout.

You need to install a plugin for eclipse so that it knows what to do about maven projects (such as m2eclipse).
Once you have that installed, you can configure it (Windows -> Preferences -> Maven) to point to your existing maven installation, and can then create maven projects via the New -> Maven Project wizard.
You can also convert existing project to maven projects via a right click -> Configure -> Convert to Maven Project.

You can download maven from from eclipse market place
Simply go to help -> eclipse market place, then search maven.
(Though i have always got it already integrated in eclipse).
After you can make various customizations to suite your needs by selecting, window -> preferences, then type in maven in the search bar ontop, you can configure the location of your settings.xml file, maven installation to use and other things you may want.
Hope this helps.

Related

What do I do with the pom.xml file?

I have just downloaded a project from github, it has a pom.xml and is missing many dependencies.
I installed m2e Maven integration in Eclipse plugin but now what do I do? It's installed and seems to be working but how do I download the dependencies now?
You checkout the git files to a location different from your Eclipse workspace.
Start Eclipse on a clean workspace and install m2e. (I usually install m2e-wtp to get web projects)
Use File -> Import -> Existing Maven projects.
Point to the pom.xml you want to use in the files checked out above.
Wait while Eclipse downloads half the Internet.
Ready.
Right click on your project, run as -> maven install.
If you can't see these, you either incorrectly installed m2e, or you need to import the project as a maven project.
In that case, delete the project from your workspace (do not check the "delete contents on disk"). Right click in the project explorer and click on import... From that dialog, you can select existing maven projects, where you need to navigate to the highest directory containing a pom.xml file.
Also, if you have maven installed on your computer (not m2e in eclipse), you can open the directory that contains the pom.xml and just type mvn clean install. This will build your project.
If you get a "Build success" message, you'll know that the dependencies have been fetched correctly.
In eclipse, You have to convert your project to a maven project. right click on your project -> maven (or configure) -> convert to maven project (or enable dependencies management).
This should update your dependencies automatically, if it is not the case then right click your project -> maven -> update project (or update dependencies, it depends on the verion of m2e you are using).
It should be enough to build the project. The dependencies should be downloaded during the build.
Pom.xml files are used for Maven projects.
Depending on your Eclipse version, maybe it's not compatible with Maven out of the box. If not, you can install a Maven plugin (like m2e) so that the project can be viewed as a Maven project.
Maven will do the dependency management (if pom.xml file is configured properly)
When you right click on your project->Run As-> Maven install it will download all the dependencies that it does not have already in your local repository.

Facing issues installing m2e maven plugin for Eclipse Juno

I installed JUNO Eclipse and then wanted to get the maven plugin for eclipse. After some searching I got to know that I can install the plugin using eclipse market place. So I searched the plugin and installed it successfully but when I restarted eclipse, I cannot see Maven option when I right click on any project. When I click on WINDOWS--> PREFERENCES , I can see the Maven option there. It means, maven got installed but not sure if completely.
I reinstalled it again but still no luck. Can anyone help?
FYI, I am using maven 3.0.4
If your project is still a standard Java project, then you have to enable Maven for this project. You can do this by right-clicking on the project, then choose Configure -> Convert to Maven project. Then you have to type group id, artifact id etc. and the pom.xml is created for you.
You need to make sure you have installed the Java JDK and add it to the Preferences -> Java -> Installed JREs.

Eclipse Marketplace - Maven Integration

I am in Eclipse Indigo and trying to install Maven Support for eclipse. I search Eclipse Marketplace with "maven" and found there are two entries:
Maven Integration for Eclipse WTP.
Maven Integration for Eclipse.
Now I am confused to choose them.
I am developing web application. So what is the entry I should go for?
Install them both. The first is specifically designed to integrate with WTP, the second one is general Maven integration in Eclipse.
Have you tried to just use Maven? With Indigo, m2e is already integrated. If you look at eclipse.org, you will find there the following features integrated:
If you open the preferences in Eclipse (Windows > Preferences), you will find there the Maven configuration for Eclipse:
You have to configure there, where your Maven installation lives, and can start to use Maven inside Eclipse.

Using m2e plugin in a Dynamic Web Project

I have an existing Dynamic Web Project in Eclipse Indigo and the m2e plugin installed. In another version of my eclipse setup that I dont quite remember (my hdd crashed) I could just right click on the project -> Maven -> Enable Dependency Management.
This menu is gone for my Dynamic Web Project in my current eclipse version. Whats the way to go now? I tried right click on the project folder -> configure -> convert to maven project but that fails with errors.
M2Eclipse has migrated to an Eclipse project from Sonatype called m2e. Therefore in you Eclipse Indigo you have installed m2e whereas your old Maven projects in the older Eclipse version were created with M2Eclipse according to your right-click description. Now under normal circomstances everything should be working flawlessly and we wouldn't have this discussion. Unfortunately with the move of the project the namespace has changed from org.maven.ide.eclipse to org.eclipse.m2e.core and old Maven projects created with M2Eclipse are not immediately recognised as Maven projects in m2e. Here's a description of how to migrate your projects accordingly.
Erik, importing an existing maven project would let m2e discover and propose you to install m2e-wtp, the Maven Integration for Eclipse WTP plugin. Since you're starting from scratch, you should install m2e-wtp yourself (see https://github.com/sonatype/m2eclipse-wtp/wiki).
Now in order to quickstart a new mavenized web project, you should go to the "New Project" menu and choose new Maven project.
At this point, either you choose to create a "simple" project, in which case you need to select the "war" packaging on the following screen, or use a maven archetype, which will quickstart a new preconfigured web project, with the flavor you want (jsf, spring ...). The m2e-wtp wiki has links to help you get started.
Note : at this point Eclipse to Maven conversion is pretty much inexistant (only creates a bare pom.xml), that's why I recommend to create a maven project first. Hopefully, this should get better in the next m2e 1.1 (June 2012)

How to create new Eclipse RCP project using Maven?

How to create new Eclipse RCP project using Maven (preferably m2eclipse)?
I read that there's plug-in for Maven that have idea about Eclipse.
(Maven Eclipse Plugin) And then it looks like I need to find some Maven Archetype to create Eclipse RCP project, but I could not. At this point I am in doubt if I go right way.
I just want to use maven dependencies resolution and other features in my RCP application development.
P.S. I found that it is possible to "Enable Dependency Management" via m2eclipse.
The other option is to make 2 project: maven project and Eclipse RCP project that will reference the first on classpath. What is the smart way?
P.P.S There's also option to use Eclipse dependency resolution mentioned here
Convert your library project to a
plug-in project (right-click ->
Configure -> Convert to Plug-in
Project) and add it to the
dependencies of your plug-in project
(manifest editor, Dependencies tab).
Maybe Tycho (http://tycho.sonatype.org/) will help you. Currently, it seems to be a little bit alpha, but after releasing Maven 3.0, Jason van Zyl promised to spend more time on Tycho (http://www.sonatype.com/people/2010/10/maven-3-0-has-landed/).
Pending all the maven3 magic highlighted in Steve's answer, you do have this Maven RCP build recipe, based on the pde-maven-plugin (as presented in the Eclipse Plugin Development Environment support page)

Categories

Resources