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 @@ -1840,19 +1840,21 @@ private boolean hasInputFileTreeChanged(IncrementalBuildHelper ibh, Set<File> in
}
Path mojoConfigFile = mojoConfigBase.resolve(INPUT_FILES_LST_FILENAME);

List<String> oldInputFiles = Collections.emptyList();
Set<String> oldInputFiles = Collections.emptySet();
if (Files.isRegularFile(mojoConfigFile)) {
try {
oldInputFiles = Files.readAllLines(mojoConfigFile);
oldInputFiles = new HashSet<>(Files.readAllLines(mojoConfigFile));
} catch (IOException e) {
// we cannot read the mojo config file, so don't do anything beside logging
getLog().warn("Error while reading old mojo status: " + mojoConfigFile);
return false;
}
}

List<String> newInputFiles =
inputFiles.stream().sorted().map(File::getAbsolutePath).collect(Collectors.toList());
Set<String> newInputFiles = inputFiles.stream()
.sorted()
.map(File::getAbsolutePath)
.collect(Collectors.toCollection(LinkedHashSet::new));

try {
Files.write(mojoConfigFile, newInputFiles);
Expand Down
24 changes: 15 additions & 9 deletions src/main/java/org/apache/maven/plugin/compiler/DeltaList.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,31 @@
*/
package org.apache.maven.plugin.compiler;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

/**
* Show the modifications between two lists.
*/
final class DeltaList<E> {
final class DeltaList<E extends Comparable<E>> {

private final List<E> added;
private final List<E> removed;
private final Set<E> added = new TreeSet<>();
private final Set<E> removed = new TreeSet<>();
private final boolean hasChanged;

DeltaList(Collection<E> oldList, Collection<E> newList) {
this.added = new ArrayList<>(newList);
this.removed = new ArrayList<>(oldList);
added.removeAll(oldList);
removed.removeAll(newList);
for (E newListItem : newList) {
if (!oldList.contains(newListItem)) {
added.add(newListItem);
}
}
for (E oldListItem : oldList) {
if (!newList.contains(oldListItem)) {
removed.add(oldListItem);
}
}
this.hasChanged = !added.isEmpty() || !removed.isEmpty();
}

Expand Down