Skip to content

Commit

Permalink
[MCOMPILER-538] Do not add generatedSourcesDirectory to the source roots
Browse files Browse the repository at this point in the history
  • Loading branch information
mensinda committed Nov 4, 2024
1 parent 642f6c3 commit 5910df7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@ public class SourcePathReadGoal extends AbstractMojo {
public void execute() throws MojoExecutionException, MojoFailureException {
if (sourceClass != null) {
getLog().info("Checking compile source roots for: '" + sourceClass + "'");
assertGeneratedSourceFileFor(sourceClass, project.getCompileSourceRoots());
List<String> roots = project.getCompileSourceRoots();
roots.add(project.getModel().getBuild().getOutputDirectory() + "/../generated-sources/annotations");
assertGeneratedSourceFileFor(sourceClass, roots);
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -821,28 +821,6 @@ public void execute() throws MojoExecutionException, CompilationFailureException
if (!generatedSourcesDirectory.exists()) {
generatedSourcesDirectory.mkdirs();
}

String generatedSourcesPath = generatedSourcesDirectory.getAbsolutePath();

compileSourceRoots.add(generatedSourcesPath);

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);
Expand Down

0 comments on commit 5910df7

Please sign in to comment.