Skip to content

Commit d434ced

Browse files
committed
[MCOMPILER-538] Do not add generatedSourcesDirectory to the source roots
1 parent d3ad8a0 commit d434ced

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
@@ -822,28 +822,6 @@ public void execute() throws MojoExecutionException, CompilationFailureException
822822
if (!generatedSourcesDirectory.exists()) {
823823
generatedSourcesDirectory.mkdirs();
824824
}
825-
826-
String generatedSourcesPath = generatedSourcesDirectory.getAbsolutePath();
827-
828-
compileSourceRoots.add(generatedSourcesPath);
829-
830-
if (isTestCompile()) {
831-
getLog().debug("Adding " + generatedSourcesPath + " to test-compile source roots:\n "
832-
+ StringUtils.join(project.getTestCompileSourceRoots().iterator(), "\n "));
833-
834-
project.addTestCompileSourceRoot(generatedSourcesPath);
835-
836-
getLog().debug("New test-compile source roots:\n "
837-
+ StringUtils.join(project.getTestCompileSourceRoots().iterator(), "\n "));
838-
} else {
839-
getLog().debug("Adding " + generatedSourcesPath + " to compile source roots:\n "
840-
+ StringUtils.join(project.getCompileSourceRoots().iterator(), "\n "));
841-
842-
project.addCompileSourceRoot(generatedSourcesPath);
843-
844-
getLog().debug("New compile source roots:\n "
845-
+ StringUtils.join(project.getCompileSourceRoots().iterator(), "\n "));
846-
}
847825
}
848826

849827
compilerConfiguration.setSourceLocations(compileSourceRoots);

0 commit comments

Comments
 (0)