mensinda commented on PR #191:
URL: 
https://github.com/apache/maven-compiler-plugin/pull/191#issuecomment-2713069230

   Ah, it has been so long that I completely forgot about that part in the 
description.
   
   Sadly, removing the generated source path from the project *is* required. 
The new testcase fails if the relevant code sections are reverted:
   
   ```diff
   diff --git 
a/src/it/setup_annotation-verify-plugin/src/main/java/org.apache.maven.plugins.compiler.it/SourcePathReadGoal.java
 
b/src/it/setup_annotation-verify-plugin/src/main/java/org.apache.maven.plugins.compiler.it/SourcePathReadGoal.java
   index d3691fa..46b7d2b 100644
   --- 
a/src/it/setup_annotation-verify-plugin/src/main/java/org.apache.maven.plugins.compiler.it/SourcePathReadGoal.java
   +++ 
b/src/it/setup_annotation-verify-plugin/src/main/java/org.apache.maven.plugins.compiler.it/SourcePathReadGoal.java
   @@ -47,17 +47,12 @@ public class SourcePathReadGoal extends AbstractMojo {
        public void execute() throws MojoExecutionException, 
MojoFailureException {
            if (sourceClass != null) {
                getLog().info("Checking compile source roots for: '" + 
sourceClass + "'");
   -            List<String> roots = project.getCompileSourceRoots();
   -            roots.add(project.getModel().getBuild().getOutputDirectory() + 
"/../generated-sources/annotations");
   -            assertGeneratedSourceFileFor(sourceClass, roots);
   +            assertGeneratedSourceFileFor(sourceClass, 
project.getCompileSourceRoots());
            }
   
            if (testSourceClass != null) {
                getLog().info("Checking test-compile source roots for: '" + 
testSourceClass + "'");
   -            List<String> roots = project.getTestCompileSourceRoots();
   -            roots.add(
   -                    project.getModel().getBuild().getOutputDirectory() + 
"/../generated-test-sources/test-annotations");
   -            assertGeneratedSourceFileFor(testSourceClass, roots);
   +            assertGeneratedSourceFileFor(testSourceClass, 
project.getTestCompileSourceRoots());
            }
        }
   
   diff --git 
a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java 
b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
   index 5631892..8a94573 100644
   --- 
a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
   +++ 
b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
   @@ -824,6 +824,26 @@ public abstract class AbstractCompilerMojo extends 
AbstractMojo {
                }
            }
   
   +        String generatedSourcesPath = 
generatedSourcesDirectory.getAbsolutePath();
   +
   +        if (isTestCompile()) {
   +            getLog().debug("Adding " + generatedSourcesPath + " to 
test-compile source roots:\n  "
   +                    + 
StringUtils.join(project.getTestCompileSourceRoots().iterator(), "\n  "));
   +
   +            project.addTestCompileSourceRoot(generatedSourcesPath);
   +
   +            getLog().debug("New test-compile source roots:\n  "
   +                    + 
StringUtils.join(project.getTestCompileSourceRoots().iterator(), "\n  "));
   +        } else {
   +            getLog().debug("Adding " + generatedSourcesPath + " to compile 
source roots:\n  "
   +                    + 
StringUtils.join(project.getCompileSourceRoots().iterator(), "\n  "));
   +
   +            project.addCompileSourceRoot(generatedSourcesPath);
   +
   +            getLog().debug("New compile source roots:\n  "
   +                    + 
StringUtils.join(project.getCompileSourceRoots().iterator(), "\n  "));
   +        }
   +
            compilerConfiguration.setSourceLocations(compileSourceRoots);
   
            compilerConfiguration.setAnnotationProcessors(annotationProcessors);
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to