Skip to content

Commit 419f1b6

Browse files
JackPGreengnodet
andauthored
Fix CompilerMojo#getSourceInclusionScanner(String) illogical addAll (#243)
Co-authored-by: Guillaume Nodet <gnodet@gmail.com>
1 parent 8b1459b commit 419f1b6

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,4 +1808,11 @@ public Logger getChildLogger(String name) {
18081808
return this;
18091809
}
18101810
}
1811+
1812+
protected static <T> Set<T> add(Set<T> t1, Set<T> t2) {
1813+
Set<T> s = new HashSet<>();
1814+
s.addAll(t1);
1815+
s.addAll(t2);
1816+
return s;
1817+
}
18111818
}

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ protected void preparePaths(Set<Path> sourceFiles) {
219219
Stream<String> s1 = Stream.of(getOutputDirectory().toString());
220220
Stream<String> s2 = session.resolveDependencies(getProject(), PathScope.MAIN_COMPILE).stream()
221221
.map(Path::toString);
222-
compilePath = Stream.concat(s1, s2).collect(Collectors.toList());
222+
compilePath = Stream.concat(s1, s2).toList();
223223
}
224224

225225
Path moduleDescriptorPath = null;
@@ -371,9 +371,7 @@ protected SourceInclusionScanner getSourceInclusionScanner(int staleMillis) {
371371
includes.add("**/*.java");
372372
}
373373

374-
Set<String> excludesIncr = new HashSet<>(excludes);
375-
excludesIncr.addAll(this.incrementalExcludes);
376-
return new StaleSourceScanner(staleMillis, includes, excludesIncr);
374+
return new StaleSourceScanner(staleMillis, includes, add(excludes, incrementalExcludes));
377375
}
378376

379377
protected SourceInclusionScanner getSourceInclusionScanner(String inputFileEnding) {
@@ -383,9 +381,7 @@ protected SourceInclusionScanner getSourceInclusionScanner(String inputFileEndin
383381
if (includes.isEmpty()) {
384382
includes.add(defaultIncludePattern);
385383
}
386-
Set<String> excludesIncr = new HashSet<>(excludes);
387-
excludesIncr.addAll(excludesIncr);
388-
return new SimpleSourceInclusionScanner(includes, excludesIncr);
384+
return new SimpleSourceInclusionScanner(includes, add(excludes, incrementalExcludes));
389385
}
390386

391387
@Override

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,7 @@ protected SourceInclusionScanner getSourceInclusionScanner(int staleMillis) {
418418
if (testIncludes.isEmpty()) {
419419
testIncludes.add("**/*.java");
420420
}
421-
Set<String> excludesIncr = new HashSet<>(testExcludes);
422-
excludesIncr.addAll(this.testIncrementalExcludes);
423-
scanner = new StaleSourceScanner(staleMillis, testIncludes, excludesIncr);
421+
scanner = new StaleSourceScanner(staleMillis, testIncludes, add(testExcludes, testIncrementalExcludes));
424422
}
425423

426424
return scanner;
@@ -439,9 +437,7 @@ protected SourceInclusionScanner getSourceInclusionScanner(String inputFileEndin
439437
if (testIncludes.isEmpty()) {
440438
testIncludes.add(defaultIncludePattern);
441439
}
442-
Set<String> excludesIncr = new HashSet<>(testExcludes);
443-
excludesIncr.addAll(this.testIncrementalExcludes);
444-
scanner = new SimpleSourceInclusionScanner(testIncludes, excludesIncr);
440+
scanner = new SimpleSourceInclusionScanner(testIncludes, add(testExcludes, testIncrementalExcludes));
445441
}
446442

447443
return scanner;

0 commit comments

Comments
 (0)