Skip to content

Commit 2cfe2a8

Browse files
committed
Remove sorting in the main path
It doesn't seem important that the file is sorted, and the output of DeltaList is only sorted if we choose to display it. Related to #334
1 parent 0d6b8e8 commit 2cfe2a8

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,10 +1851,8 @@ private boolean hasInputFileTreeChanged(IncrementalBuildHelper ibh, Set<File> in
18511851
}
18521852
}
18531853

1854-
Set<String> newInputFiles = inputFiles.stream()
1855-
.sorted()
1856-
.map(File::getAbsolutePath)
1857-
.collect(Collectors.toCollection(LinkedHashSet::new));
1854+
Set<String> newInputFiles =
1855+
inputFiles.stream().map(File::getAbsolutePath).collect(Collectors.toCollection(HashSet::new));
18581856

18591857
try {
18601858
Files.write(mojoConfigFile, newInputFiles);
@@ -1866,10 +1864,13 @@ private boolean hasInputFileTreeChanged(IncrementalBuildHelper ibh, Set<File> in
18661864

18671865
DeltaList<String> inputTreeChanges = new DeltaList<>(oldInputFiles, newInputFiles);
18681866
if (getLog().isDebugEnabled() || showCompilationChanges) {
1869-
for (String fileAdded : inputTreeChanges.getAdded()) {
1867+
// we only sort the output when pushed to the user
1868+
for (String fileAdded :
1869+
inputTreeChanges.getAdded().stream().sorted().collect(Collectors.toList())) {
18701870
getLog().info("\tInput tree files (+): " + fileAdded);
18711871
}
1872-
for (String fileRemoved : inputTreeChanges.getRemoved()) {
1872+
for (String fileRemoved :
1873+
inputTreeChanges.getRemoved().stream().sorted().collect(Collectors.toList())) {
18731874
getLog().info("\tInput tree files (-): " + fileRemoved);
18741875
}
18751876
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ final class DeltaList<E> {
3333
private final boolean hasChanged;
3434

3535
DeltaList(Collection<E> oldList, Collection<E> newList) {
36-
this.added = newList.stream().filter(i -> !oldList.contains(i)).sorted().collect(Collectors.toList());
37-
this.removed =
38-
oldList.stream().filter(i -> !newList.contains(i)).sorted().collect(Collectors.toList());
36+
this.added = newList.stream().filter(i -> !oldList.contains(i)).collect(Collectors.toList());
37+
this.removed = oldList.stream().filter(i -> !newList.contains(i)).collect(Collectors.toList());
3938
this.hasChanged = !added.isEmpty() || !removed.isEmpty();
4039
}
4140

0 commit comments

Comments
 (0)