Skip to content

Commit 9b86939

Browse files
committed
[MCOMPILER-538] Do not add generatedSourcesDirectory to the source roots
1 parent 44d85d4 commit 9b86939

File tree

2 files changed

+7
-24
lines changed

2 files changed

+7
-24
lines changed

src/it/setup_annotation-verify-plugin/src/main/java/org.apache.maven.plugins.compiler.it/SourcePathReadGoal.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,17 @@ public class SourcePathReadGoal extends AbstractMojo {
4747
public void execute() throws MojoExecutionException, MojoFailureException {
4848
if (sourceClass != null) {
4949
getLog().info("Checking compile source roots for: '" + sourceClass + "'");
50-
assertGeneratedSourceFileFor(sourceClass, project.getCompileSourceRoots());
50+
List<String> roots = project.getCompileSourceRoots();
51+
roots.add(project.getModel().getBuild().getOutputDirectory() + "/../generated-sources/annotations");
52+
assertGeneratedSourceFileFor(sourceClass, roots);
5153
}
5254

5355
if (testSourceClass != null) {
5456
getLog().info("Checking test-compile source roots for: '" + testSourceClass + "'");
55-
assertGeneratedSourceFileFor(testSourceClass, project.getTestCompileSourceRoots());
57+
List<String> roots = project.getTestCompileSourceRoots();
58+
roots.add(
59+
project.getModel().getBuild().getOutputDirectory() + "/../generated-test-sources/test-annotations");
60+
assertGeneratedSourceFileFor(testSourceClass, roots);
5661
}
5762
}
5863

src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java

-22
Original file line numberDiff line numberDiff line change
@@ -821,28 +821,6 @@ public void execute() throws MojoExecutionException, CompilationFailureException
821821
if (!generatedSourcesDirectory.exists()) {
822822
generatedSourcesDirectory.mkdirs();
823823
}
824-
825-
String generatedSourcesPath = generatedSourcesDirectory.getAbsolutePath();
826-
827-
compileSourceRoots.add(generatedSourcesPath);
828-
829-
if (isTestCompile()) {
830-
getLog().debug("Adding " + generatedSourcesPath + " to test-compile source roots:\n "
831-
+ StringUtils.join(project.getTestCompileSourceRoots().iterator(), "\n "));
832-
833-
project.addTestCompileSourceRoot(generatedSourcesPath);
834-
835-
getLog().debug("New test-compile source roots:\n "
836-
+ StringUtils.join(project.getTestCompileSourceRoots().iterator(), "\n "));
837-
} else {
838-
getLog().debug("Adding " + generatedSourcesPath + " to compile source roots:\n "
839-
+ StringUtils.join(project.getCompileSourceRoots().iterator(), "\n "));
840-
841-
project.addCompileSourceRoot(generatedSourcesPath);
842-
843-
getLog().debug("New compile source roots:\n "
844-
+ StringUtils.join(project.getCompileSourceRoots().iterator(), "\n "));
845-
}
846824
}
847825

848826
compilerConfiguration.setSourceLocations(compileSourceRoots);

0 commit comments

Comments
 (0)