Skip to content

Commit 1fd45ce

Browse files
committed
[MCOMPILER-540] - useIncrementalCompilation=false may add generated sources to the sources list
1 parent 9548c6c commit 1fd45ce

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,6 +1000,7 @@ private void executeReal() throws MojoExecutionException, CompilationFailureExce
10001000
return;
10011001
}
10021002

1003+
staleSources = filterSourceFiles(staleSources);
10031004
compilerConfiguration.setSourceFiles(staleSources);
10041005

10051006
try {
@@ -1887,6 +1888,17 @@ public void setRelease(String release) {
18871888
targetOrReleaseSet = true;
18881889
}
18891890

1891+
private Set<File> filterSourceFiles(Set<File> sourceFiles) {
1892+
final File generatedSources = getGeneratedSourcesDirectory();
1893+
if (generatedSources == null) {
1894+
return sourceFiles;
1895+
}
1896+
final String generatedSourcesPath = generatedSources.getAbsolutePath();
1897+
return sourceFiles.stream()
1898+
.filter(x -> !x.getAbsolutePath().startsWith(generatedSourcesPath))
1899+
.collect(Collectors.toSet());
1900+
}
1901+
18901902
final String getImplicit() {
18911903
return implicit;
18921904
}

0 commit comments

Comments
 (0)