How can I configure Maven (and update) the build path for my Eclipse project?

I define dependencies for compiling, testing, and running my programs in pom.xml files. But Eclipse still has a separately configured build path, so whenever I change either, I have to manually update another one. I think this can be avoided? How?

+1
source share
3 answers

Use m2eclipse or IAM (formerly Q4E ). Both provide (among other functions) a means of recalculating Maven dependencies whenever a clean build is performed, and represent Eclipse dependencies as a container of the classpath. See the Eclipse Maven integration comparison for more details.

I would personally go to m2eclipse for now, especially if you are doing development with AspectJ. There is an additional plugin for m2eclipse that provides aspect libraries from aspectj-maven-plugin for Eclipse, which avoids a whole class of integration issues.

To enable m2eclipse in an existing project, right-click it in the Package Explorer view, then select Maven โ†’ Enable Dependency Management . >, this will add the Maven constructor to the .project file and the container container of the path to the .classpath file.

There is also an eclipse target: eclipse, but I found that this is more of a problem than it costs, as it creates very simple .project and .classpath files (although this is useful for initial project setup), so if you have any complications to your configuration you will have to reapply them every time. In fairness, it should be said that it was an older version, and now it is better to deal with edge cases.

+5
source

Running mvn eclipse: eclipse will create eclipse files from your maven project, but you have to run it every time you change pom.xml. Installing the eclipse maven plugin might seem like m2eclipse might keep it up to date

+1
source

I highly recommend you check out the M2Eclipse Plugin . He will take care to keep the path up to date.

0
source

All Articles