Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CompilerMojo#getSourceInclusionScanner(String) illogical addAll #243

Merged
merged 6 commits into from
Jul 8, 2024
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 @@ -1788,4 +1788,11 @@ public Logger getChildLogger(String name) {
return this;
}
}

protected static <T> Set<T> add(Set<T> t1, Set<T> t2) {
Set<T> s = new HashSet<>();
s.addAll(t1);
s.addAll(t2);
return s;
}
}
10 changes: 3 additions & 7 deletions src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ protected void preparePaths(Set<Path> sourceFiles) {
Stream<String> s1 = Stream.of(getOutputDirectory().toString());
Stream<String> s2 = session.resolveDependencies(getProject(), PathScope.MAIN_COMPILE).stream()
.map(Path::toString);
compilePath = Stream.concat(s1, s2).collect(Collectors.toList());
compilePath = Stream.concat(s1, s2).toList();
}

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

Set<String> excludesIncr = new HashSet<>(excludes);
excludesIncr.addAll(this.incrementalExcludes);
return new StaleSourceScanner(staleMillis, includes, excludesIncr);
return new StaleSourceScanner(staleMillis, includes, add(excludes, incrementalExcludes));
}

protected SourceInclusionScanner getSourceInclusionScanner(String inputFileEnding) {
Expand All @@ -383,9 +381,7 @@ protected SourceInclusionScanner getSourceInclusionScanner(String inputFileEndin
if (includes.isEmpty()) {
includes.add(defaultIncludePattern);
}
Set<String> excludesIncr = new HashSet<>(excludes);
excludesIncr.addAll(excludesIncr);
return new SimpleSourceInclusionScanner(includes, excludesIncr);
return new SimpleSourceInclusionScanner(includes, add(excludes, incrementalExcludes));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,7 @@ protected SourceInclusionScanner getSourceInclusionScanner(int staleMillis) {
if (testIncludes.isEmpty()) {
testIncludes.add("**/*.java");
}
Set<String> excludesIncr = new HashSet<>(testExcludes);
excludesIncr.addAll(this.testIncrementalExcludes);
scanner = new StaleSourceScanner(staleMillis, testIncludes, excludesIncr);
scanner = new StaleSourceScanner(staleMillis, testIncludes, add(testExcludes, testIncrementalExcludes));
}

return scanner;
Expand All @@ -439,9 +437,7 @@ protected SourceInclusionScanner getSourceInclusionScanner(String inputFileEndin
if (testIncludes.isEmpty()) {
testIncludes.add(defaultIncludePattern);
}
Set<String> excludesIncr = new HashSet<>(testExcludes);
excludesIncr.addAll(this.testIncrementalExcludes);
scanner = new SimpleSourceInclusionScanner(testIncludes, excludesIncr);
scanner = new SimpleSourceInclusionScanner(testIncludes, add(testExcludes, testIncrementalExcludes));
}

return scanner;
Expand Down