I have a maven project in eclipse and have maven goals that run annotation processors to generate code. The output folder for this code is target/generated-sources/apt
.
In order for Eclipse to see this generated code I need to add target/generated-sources/apt
as a source folder to the Eclipse project.
However, this causes there to be an error of type "Maven Configuration Problem" saying
Project configuration is not up-to-date with
pom.xml
. Run project configuration update
I think I understand why this is the case as Eclipse has a different set of source folders to Maven's set. But I need this different set, as I need Eclipse to be able to see the generated
source folders...
When doing a pure Maven built, these source folders will be included in the build, by Maven.
BTW, I have upgraded to the official Eclipse release of the Maven Eclipse plugin, m2e 1.0 - what used to be m2eclipse. I'd like to see if I can find a work around/solution to this with the m2e plugin before I have to go back to the old m2eclipse version.
This plugin synchronises the settings done in your project's Maven POM file with the Eclipse settings. All you need to provide is a JAR file with the settings files, and configure the maven-eclipse-plugin in your POM to use these settings.
m2e is a popular Eclipse IDE plugin with stated project goal "to provide a first-class Apache Maven support in the Eclipse IDE".
M2Eclipse provides tight integration for Apache Maven into the Eclipse IDE with the following features: Launching Maven builds from within Eclipse. Dependency management for Eclipse build path based on Maven's pom. xml. Resolving Maven dependencies from the Eclipse workspace without installing to local Maven repository.
You need to attach the source directory with the build-helper-plugin.
Like so:
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> <executions> <execution> <id>add-source</id> <phase>generate-sources</phase> <goals> <goal>add-source</goal> </goals> <configuration> <sources> <source>${project.build.directory}/generated-sources/java/</source> </sources> </configuration> </execution> </executions> </plugin>
You will also need to:
Right-click the Error message:
Project configuration is not up-to-date with pom.xml Run project configuration update
in the Problems View and select Quick Fix and click Finish to select the default Update project configuration. This fixes it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With