Skip to content
Merged
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 @@ -703,8 +703,39 @@ protected final Optional<Path> getModuleDeclaration(final Set<File> sourceFiles)
private boolean targetOrReleaseSet;

@Override
@SuppressWarnings("checkstyle:MethodLength")
public void execute() throws MojoExecutionException, CompilationFailureException {
try {
executeReal();
} finally {
addGeneratedSourcesToProject();
}
}

private void addGeneratedSourcesToProject() {
File generatedSourcesDirectory = getGeneratedSourcesDirectory();
if (generatedSourcesDirectory == null) {
return;
}

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);
}
}

@SuppressWarnings("checkstyle:MethodLength")
private void executeReal() throws MojoExecutionException, CompilationFailureException {
// ----------------------------------------------------------------------
// Look up the compiler. This is done before other code than can
// cause the mojo to return before the lookup is done possibly resulting
Expand Down