How can I make eclipse make use of packages downloaded by maven? - java

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.

Related

Does Eclipse use maven?

I can't understand Gradle and Maven in Eclipse. I know that Gradle, Maven is a build automation system.
In Android Studio it uses Gradle and I can see the files to configure them.
But I can't find them in Eclipse? Does Eclipse use Maven or Gradle? Where can I confige it.
There are Maven and Gradle plugins in Eclipse, which usually come preinstalled. You can generate Maven or Gradle projects in your workspace.

Maven project JARs weirdly structured

I am using Maven m2e as my Eclipse project.
My Maven project was acting weird so I right clicked my pom.xml and went to run as -> maven build then under goals I first did eclipse:clean and then eclipse:eclipse. Before I did that all my JARs were inside the Maven Dependencies folder. Now most of my jars are located in my project folder, outside the maven dependencies folder. Why is that? And how can I revert those changes?
This is how it looks now:
mvn eclipse:eclipse is a relic from ancient times, don't use it.
Basically, what it does is taking the information from a pom.xml and using it to create a native Eclipse project. That was a nice approach 5 years ago, when Eclipse didn't understand Maven projects, but ever since m2eclipse / m2e were introduced, this approach was deprecated in favor of these plugins that actually try to understand the pom.xml.

Include a Netbeans Maven project in a Netbeans Ant project

I have a Netbeans Ant project that uses a Jar file generated from a Netbeans Maven project. I would like to "include" the Maven project directly in the Ant project to be able to proper debug both projects. The Maven project was converted from an Ant project and before the conversion this include was possible. I have control over both projects, but converting the Ant project to a Maven project is not really an option at this point. What is the best approach to make an Ant based project and a Maven based project "work" together i Netbeans?
Thanks
it should work if your ant project includes the maven local repository jar as dependency. Maven support does automatic binary->open project source conversion for local repo artifacts.

Eclipse Maven Export Missing

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).

Maven dependecny is not available in eclipse java build path

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

Categories