Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,22 @@ public void execute() throws MojoExecutionException, CompilationFailureException
}
}

String generatedSourcesPath = generatedSourcesDirectory.getAbsolutePath();

if (isTestCompile()) {
getLog().debug("Adding " + generatedSourcesPath
+ " to the project test-compile source roots but NOT the actual test-compile source roots:\n "
+ StringUtils.join(project.getTestCompileSourceRoots().iterator(), "\n "));

project.addTestCompileSourceRoot(generatedSourcesPath);
} else {
getLog().debug("Adding " + generatedSourcesPath
+ " to the project compile source roots but NOT the actual compile source roots:\n "
+ StringUtils.join(project.getCompileSourceRoots().iterator(), "\n "));

project.addCompileSourceRoot(generatedSourcesPath);
}

compilerConfiguration.setSourceLocations(compileSourceRoots);

compilerConfiguration.setAnnotationProcessors(annotationProcessors);
Expand Down Expand Up @@ -1122,6 +1138,9 @@ public void execute() throws MojoExecutionException, CompilationFailureException
} else if (getOutputDirectory().toPath().startsWith(filePath)) {
// multirelease, can be ignored
continue;
} else if (generatedSourcesDirectory.toPath().startsWith(filePath)) {
// ignore generated sources
continue;
} else if (sourceRoots.contains(filePath)) {
patchModules.add("_"); // this jar
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
Expand Down Expand Up @@ -182,7 +183,14 @@ public class CompilerMojo extends AbstractCompilerMojo {

@Override
protected List<String> getCompileSourceRoots() {
return compileSourceRoots;
if (generatedSourcesDirectory == null) {
return compileSourceRoots;
} else {
String generatedSourceRoot = generatedSourcesDirectory.getAbsolutePath();
return compileSourceRoots.stream()
.filter(x -> !Objects.equals(x, generatedSourceRoot))
.collect(Collectors.toList());
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
Expand Down Expand Up @@ -209,7 +211,14 @@ public void execute() throws MojoExecutionException, CompilationFailureException
}

protected List<String> getCompileSourceRoots() {
return compileSourceRoots;
if (generatedTestSourcesDirectory == null) {
return compileSourceRoots;
} else {
String generatedSourceRoot = generatedTestSourcesDirectory.getAbsolutePath();
return compileSourceRoots.stream()
.filter(x -> !Objects.equals(x, generatedSourceRoot))
.collect(Collectors.toList());
}
}

@Override
Expand Down