Goal eclipse:eclipse
is able to generate a valid configuration for Eclipse based on its pom.xml
. Basically what it does is overwrite the .classpath
file of your project.
The problem with this is that every time you change the pom.xml
you need to run the command again and the build and execution run within Eclipse does not generally respect all Maven settings, since they are performed separately.
Integrating Maven into Eclipse is preferably done using the M2E plugin, which is installed in Eclipse and already comes in "Eclipse for Java EE". This plugin configures recognizes changes in Maven and manages to make the necessary updates in Eclipse. It also allows you to run self-generating code when you save your classes, as well as other facilities.
If M2E does not automatically add classpaths to the classpath, it is because you have to set up your pom.xml
using build-helper-plugin
to add the directory where classes are generated. See documentation examples .
Remember that the Eclipse classpath and the Maven classpath are different things. Be careful not to fall into the trap of altering the Eclipse project manually and thinking that everything is fine. In a Maven project, the Eclipse classpath is just something that must be derived from the Maven configuration and may not faithfully reproduce the classpath when you run Maven from the command line.