I am using MapStruct to generate some Entity to DTO mappers. I have an abstract mapper defined, and I created some tests for it using a test entity, test dto, and test mapper. These test files live in the src/test/java folder, but when MapStruct generates the implementation for the test mapper it puts the generated source in the target/generated-sources folder instead of the target/generated-test-sources folder. This causes the class to get compiled into the actual jar file which I don't want.
[UPDATE] I have put up an example that recreates the problem here:
https://github.com/niltz/so-51090868-example
Seems like it works fine when I run the build with maven on the command line, but when I import the pom into Spring Tool Suite, I get the issue.
Seems like it is an issue with the m2e eclipse plugin while using JDT APT, the maven-compiler-plugin, and an older version of eclipse.
https://marketplace.eclipse.org/content/m2e-apt
Apparently I need to ensure that I use Eclipse Photon or higher, or I can use the maven-processor-plugin instead. I chose to upgrade Eclipse and it seems to work now.
https://bsorrentino.github.io/maven-annotation-plugin/