This plugin calls MavenProject.addCompileSourceRoot() and MavenProject.addTestCompileSourceRoot() from AbstractJavaGenreatorMojo.performExecution(). This method is called by AbstractJaxbMojo.execute(). However, the test code is only added if AbstractJaxbMojo.isReGenerationRequired() returns true for the generated test code. This means, that other Maven plugin cannot depend on these source files being available if the generated code is not regenerated in the current Maven run.
As an example pipeline, may perform the following steps.
Verify it Builds - mvn clean install -DskipTests=true
Run Tests and Compute Coverage (using JaCoCo) - mvn test -P coverage
It appears that enabling JaCoCo Because Jacoc results in our test source code being recompiled. Because the tests XSDs (or generated sources for that matter) were not modified, the generated test source is not added to the Maven project. Note the current implementation is potentially adding test source code as real source code. This could cause all sorts of other issues.
Please update the plugin to always add the the test source code to the Maven project regardless of whether or not the sources need to recompiled. I believe this can be solved generically by updating the following.
Move AbstractJavaGeneratorMojo.addGeneratedSourcesToProjectSourceRoot() up into AbstractJaxbMojo.
Modify AbstractXsdGeneratorMojo have a no op implementation of this method.
Modify AbstractJaxbMojo.execute() line 364 (getProject().addCompileSourceRoot(canonicalPathToOutputDirectory) to call addGeneratedSourcesToProjectSourceRoot().
Remove call to addGeneratedSourcesToProjectSourceRoot() from AbstactJavaGeneratorMojo.performExecution().
I have attached the updated files that tested with to ensure it solved our issue.
This plugin calls MavenProject.addCompileSourceRoot() and MavenProject.addTestCompileSourceRoot() from AbstractJavaGenreatorMojo.performExecution(). This method is called by AbstractJaxbMojo.execute(). However, the test code is only added if AbstractJaxbMojo.isReGenerationRequired() returns true for the generated test code. This means, that other Maven plugin cannot depend on these source files being available if the generated code is not regenerated in the current Maven run.
As an example pipeline, may perform the following steps.
It appears that enabling JaCoCo Because Jacoc results in our test source code being recompiled. Because the tests XSDs (or generated sources for that matter) were not modified, the generated test source is not added to the Maven project. Note the current implementation is potentially adding test source code as real source code. This could cause all sorts of other issues.
Please update the plugin to always add the the test source code to the Maven project regardless of whether or not the sources need to recompiled. I believe this can be solved generically by updating the following.
I have attached the updated files that tested with to ensure it solved our issue.
updates.zip