The Goal eclipse:eclipse
is able to generate a valid configuration for Eclipse based on your pom.xml
. Basically what it does is overwrite the file .classpath
of your project.
The problem with that is that every time you change the pom.xml
need to run the command again and the compilation and execution performed within Eclipse generally does not respect all Maven settings, since they are executed separately.
Integrating Maven into Eclipse is preferably done using the M2E plugin, which is installed in Eclipse and comes in "Eclipse for Java EE". This plugin configures recognizes changes in Maven and can make the necessary updates in Eclipse. It also allows you to run auto-generation code when you save your classes, plus other facilities.
If M2E does not add the generated classes to the classpath automatically, it is because its pom.xml
using the build-helper-plugin
to add the directory where classes are generated. See examples of use in documentation.
Remember that the Eclipse classpath and Maven classpath are different things. Be careful not to fall into the trap of changing the Eclipse project manually and find that everything is fine. In a Maven project, the Eclipse classpath is just something that should be derived from the Maven configuration and may not faithfully reproduce the classpath when you run Maven per command line.
One way I discovered was to execute the mvn eclipse:eclipse command
– renanlessa