diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginValidationManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginValidationManager.java index 0794a548f716..cf15292df8df 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginValidationManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultPluginValidationManager.java @@ -23,6 +23,7 @@ import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -222,7 +223,12 @@ private void reportSessionCollectedValidationIssues(MavenSession mavenSession) { logger.warn(""); logger.warn("Plugin {} validation issues were detected in following plugin(s)", issueLocalitiesToReport); logger.warn(""); - for (Map.Entry entry : issuesMap.entrySet()) { + + // Sorting the plugins + List> sortedEntries = new ArrayList<>(issuesMap.entrySet()); + sortedEntries.sort(Map.Entry.comparingByKey(String.CASE_INSENSITIVE_ORDER)); + + for (Map.Entry entry : sortedEntries) { PluginValidationIssues issues = entry.getValue(); if (!hasAnythingToReport(issues, issueLocalitiesToReport)) { continue; diff --git a/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java b/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java index 39d7bb30d78f..54537a4a5acf 100644 --- a/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java +++ b/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java @@ -18,11 +18,13 @@ */ package org.apache.maven.model; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * Tests {@code Dependency}. @@ -30,6 +32,16 @@ */ class DependencyTest { + private Dependency dependency; + + @BeforeEach + public void setUp() { + dependency = new Dependency(); + dependency.setGroupId("groupId"); + dependency.setArtifactId("artifactId"); + dependency.setVersion("1.0"); + } + @Test void testHashCodeNullSafe() { new Dependency().hashCode(); @@ -52,4 +64,18 @@ void testEqualsIdentity() { void testToStringNullSafe() { assertNotNull(new Dependency().toString()); } + + @Test + public void testDependencyExclusions() { + Exclusion exclusion = new Exclusion(); + exclusion.setGroupId("excludedGroupId"); + exclusion.setArtifactId("excludedArtifactId"); + + dependency.addExclusion(exclusion); + + assertEquals(1, dependency.getExclusions().size()); + Exclusion addedExclusion = dependency.getExclusions().get(0); + assertEquals("excludedGroupId", addedExclusion.getGroupId()); + assertEquals("excludedArtifactId", addedExclusion.getArtifactId()); + } }