Skip to content

Commit

Permalink
[MDEP-832] - Remove commons-collections-4
Browse files Browse the repository at this point in the history
  • Loading branch information
khmarbaise committed Aug 11, 2023
1 parent 0243c41 commit c6973da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,6 @@ under the License.
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>

<!-- dependencies to annotations -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

import java.io.IOException;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
Expand Down Expand Up @@ -131,14 +131,11 @@ private void createMessage(
}

private Set<String> findDuplicateDependencies(List<Dependency> modelDependencies) {
List<String> modelDependencies2 = new ArrayList<>();
for (Dependency dep : modelDependencies) {
modelDependencies2.add(dep.getManagementKey());
}

// @formatter:off
return new LinkedHashSet<>(
CollectionUtils.disjunction(modelDependencies2, new LinkedHashSet<>(modelDependencies2)));
// @formatter:on
List<String> modelDependencies2 =
modelDependencies.stream().map(Dependency::getManagementKey).collect(Collectors.toList());
// remove one instance of each element from the list
modelDependencies2.removeIf(new HashSet<>(modelDependencies2)::remove);
// keep a single instance of each duplicate
return new LinkedHashSet<>(modelDependencies2);
}
}

0 comments on commit c6973da

Please sign in to comment.