4

I'm using MapStruct with maven as descriped in the documentation (http://mapstruct.org/documentation/stable/reference/html/). Now I'd like to change the location of the generated mapper classes from target to source folder. I've read How to chanage the mapstruct generated classes location and M2E and having maven generated source folders as eclipse source folders and got it working by using the maven-processor-plugin (the apt-maven-plugin might work too). In addition to that I had to remove the annotationProcessorPaths from the maven-compiler-plugin. Otherwise the maven builds failed because the generated code was duplicated under "generated-sources" (the changed output folder) and "target\generated-sources\annotations" (the default output folder). But now every time I hit "Maven" --> "Update Project" in eclipse I have to re-enable "enable annotation processing" in the project properties. And when I change the "Generated source directory" in eclipse by hand it will also be overridden.

So is it possible to change the output directory in maven and keep "Enable annotation processing" enabled in eclipse ? I'm using eclipse JEE oxygen with the MapStruct and m2e-apt plugin installed. If it helps I'm using also Spring Boot 1.5.9

merlin-hst
  • 61
  • 1
  • 4

1 Answers1

5

What you are looking for is the generatedSourcesDirectory option of the maven-compiler. That property controls where the Java Annotation Processor will output the generated sources.

I think that if you set that, the integration between Eclipse and Maven should work correctly and you should get everything without the need of the build-helper-maven-plugin

Filip
  • 19,269
  • 7
  • 51
  • 60