I'm using Eclipse Kepler 64 bit. It already has m2e (maven plugin) pre-installed by default.
The import wizard has a Maven option but the export one doesn't:
I tried installing m2e from the Marketplace but it said that there was nothing to install.
How do I get it as export option as well?
As far as the M2E plugin is concerned, using Maven with Eclipse involve importing existing project, and making sure the pom.xml is complete (with the right "nature" added in it, in order to generate the right .project, as in this example)
See "Importing Maven Projects" in the Sonatype book.
But once the project is imported, it becomes a regular project (with additional maven capabilities), without any maven-specific export options.
All you need to "export" a maven project are the sources and the pom.xml: anyone can then run maven to get all the dependencies (from the pom.xml specifications).
Related
In an eclipse project, I referenced a class that was currently not in project's build path.
In the context sensitive pop-up that opens by hovering the mouse over the error, "Fix project setup" option has offered me to add a jar to the build path of the project. This jar is in my local maven repository.
However, the "correct" way to fix it is obviously by adding the relevant dependencies to my project's pom, instead of adding this jar to the build path of the project.
So is there a way to configure eclipse, so that it won't offer to add a maven repo jar to the build path, but it will offer to fix the project's pom?
This feature used to exist in m2eclipse (the predecessor of m2e), see e.g.
https://blog.sonatype.com/2010/03/adding-dependencies-using-m2eclipse/ which shows a "Search dependency for XXX" quickfix above the "Fix project setup..." quickfix.
Unfortunately it didn't make it into m2e, see https://www.eclipse.org/lists/m2e-users/msg01130.html
Make sure:
your project is fine outside of eclipse using only maven/pom, mvn
clean install (or similar) in an external shell/console
your eclipse project has maven nature
Eclipse -> Project -> Build Automatically is checked
Refresh your eclipse project
Do something in the pom.xml (save file) should trigger a build
I checked out an existing eclipse project from SVN. Then I converted it to Maven project.
The project is compile with Maven target clean install perfectly no problem. But the eclipse doesn't identify any dependency jar file. Basically it does not know the Maven repo path. It knows only JDK path. So all my java classes are with full of red lines.
Everything in this site and google I checked all fine. But why eclipse can not find the mvn repo?
eclipse version = JUNO Version: 4.2.2. ( I think this has inbuilt maven plugin)
Maven plugin detail = M2E - Maven Integration for Eclipse version - 1.4.0, Provider - Eclipse.org -m2e
UPDATE ======================
If I checkout the source code separately and import it as a maven project that way its working. But I want to know why if I checkout the code through Subclipse and convert it to maven project is not working?
Run
# use maven to control your eclipse .project and .classpath files, that is
mvn eclipse:clean
mvn eclipse:eclipse
and then restart your eclipse (or switch your workspace and then back).
Make sure you have the m2e plugin, - from here, you should read the Release Notes and add this to your update sites - "http://download.eclipse.org/releases/juno" and "http://download.eclipse.org/technology/m2e/releases".
In Eclipse, you can actually create an external tool Run> External Tools> External Tools Configurations. After this you can select your project that you want to setup and run this external tool.
or if you have maven plugin installed in eclipse, select your project right click Run As > Maven Build... (see below image). In Goals put "eclipse:eclipse" and click Run
When I use Maven compile, it will automatically download the depended java packages for me. Now, to debug the project, I import the project into Eclipse, but in Eclipse, the depended package is still missing. How can I get the packages? Or, can Eclipse use packages downloaded by Maven?
You don't really need to manually add all the dependencies downloaded by maven to the classpath in Eclipse. There is a maven-2-eclipse plugin which integrates maven with Eclipse. Using that plugin you can
import/create a project as Maven project or
convert an existing project into a maven project
Your Eclipse will automatically add all the downloaded dependencies on the class path everytime.
An alternative to the m2e eclipse maven plugin suggested by rocketboy is to use the maven eclipse plugin. This works from the command line (mvn eclipse:eclipse), and generates Eclipse settings for your project by downloading dependencies and putting them onto the Eclipse build path.
I imported a Maven project into Eclipse. I was able to deploy it from the command line. In Eclipse it is full of red Xs. I have cleaned the project, updated the configuration and I ran the following command:
mvn -Declipse.workspace=<pathtoworksapce> eclipse:add-maven-repo
and I still have the same problem. The project is dependent on another project.
What I ended up doing was removing all of the projects in Eclipse, but not deleting the source files. Then instead of directly importing the code as Maven->Check out as Maven Projects with SCM, I selected Existing Maven Project and imported the code from my local machine. This got rid of the errors, but when I would right click on code and select "Open Declaration", I would get Error: Could not open the editor: The file does not exist" So I removed all projects again and this time I deleted all the ".project" files and repeated the import Existing Maven Project. So now there are no red Xs (dependency problems) and the lookup functionality within the code works.
Go to your master project and type the following :
mvn install
mvn eclipse:eclipse
After that, import your project. You can also install m2eclipse for better support. If you use gwt or any other framework which has a custom maven execution, you should also install plugins for those in Eclipse.
I've got project with a few sub modules.
mvn clean install
works absolutely fine. But in Eclipse with the parent project open none of the maven dependencies are available and so all my Java source files are full of indicated compilation errors (they're not listed in the build path for the project). If I open one of the sub modules as a project there are no indicated compilation problems.
I've tried running
mvn clean install eclipse:clean eclipse:m2eclipsemvn clean install eclipse:clean eclipse:m2eclipse
and choosing project / update maven dependencies. Refreshing, closing and opening the project and Eclipse, etc.
Any ideas? Thanks in advance.
Getting m2eclipse to match maven's classpath
Just use Import... > Existing Maven Projects and import your multi-modules Maven project, that's all.
But in Eclipse with the parent project open none of the maven dependencies are available and so all my Java source files are full of indicated compilation errors (they're not listed in the build path for the project).
A parent project (i.e. with a pom packaging) is not a Java project, it's just there as a facility to make editing the parent pom.xml from the IDE possible (and that's already nice, importing nested projects inside Eclipse was initially not even possible).
If I open one of the sub modules as a project there are no indicated compilation problems.
That's how you are supposed to do things.
I've tried running (...)
You are not supposed to use the Maven Eclipse Plugin when using m2eclipse and this is not supported. Either use one or the other. If you decide to use m2eclipse, use Import... > Existing Maven Projects as suggested.