From 1a1df66bfb0241a296f766bc8e4d4f708f69c9ab Mon Sep 17 00:00:00 2001 From: Yueh Chun Wu Date: Thu, 16 May 2024 22:03:26 -0700 Subject: [PATCH 1/5] [MNG-7902] Sort plugins in the validation report --- .../DefaultPluginValidationManager.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) 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..a20f9bf69ac3 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,17 +23,7 @@ import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.EnumSet; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -203,7 +193,7 @@ public void reportPluginMojoValidationIssue( mayReportInline(mavenSession.getRepositorySession(), locality, issue); } - private void reportSessionCollectedValidationIssues(MavenSession mavenSession) { + public void reportSessionCollectedValidationIssues(MavenSession mavenSession) { if (!logger.isWarnEnabled()) { return; // nothing can be reported } @@ -222,7 +212,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 (Fix the open issue) + 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; From 3f9baa55d0aa1f33cd601b58a44dffcd4a83b0b1 Mon Sep 17 00:00:00 2001 From: Yueh Chun Wu Date: Wed, 22 May 2024 14:57:57 -0700 Subject: [PATCH 2/5] [MNG-7902] Sort plugins in the validation report remove * from import statements and remove unnecessary comment --- .../internal/DefaultPluginValidationManager.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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 a20f9bf69ac3..a3aff36611c5 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,7 +23,18 @@ import java.nio.file.Path; import java.nio.file.Paths; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; @@ -213,7 +224,7 @@ public void reportSessionCollectedValidationIssues(MavenSession mavenSession) { logger.warn("Plugin {} validation issues were detected in following plugin(s)", issueLocalitiesToReport); logger.warn(""); - // Sorting the plugins (Fix the open issue) + // Sorting the plugins List> sortedEntries = new ArrayList<>(issuesMap.entrySet()); sortedEntries.sort(Map.Entry.comparingByKey(String.CASE_INSENSITIVE_ORDER)); From 32f9d3af1fdc0093ec08a4ece91254b8fc0d7ba0 Mon Sep 17 00:00:00 2001 From: Yueh Chun Wu Date: Wed, 22 May 2024 15:15:10 -0700 Subject: [PATCH 3/5] [MNG-7902] Sort plugins in the validation report Incorrect visibility change --- .../maven/plugin/internal/DefaultPluginValidationManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a3aff36611c5..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 @@ -204,7 +204,7 @@ public void reportPluginMojoValidationIssue( mayReportInline(mavenSession.getRepositorySession(), locality, issue); } - public void reportSessionCollectedValidationIssues(MavenSession mavenSession) { + private void reportSessionCollectedValidationIssues(MavenSession mavenSession) { if (!logger.isWarnEnabled()) { return; // nothing can be reported } From eafb35a9058876dfe35d02baae73ed57b413116e Mon Sep 17 00:00:00 2001 From: Yueh Chun Wu Date: Mon, 27 May 2024 18:26:43 -0700 Subject: [PATCH 4/5] Add new test cases for DependencyTest --- .../apache/maven/model/DependencyTest.java | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) 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..df8768664e15 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,10 @@ */ 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.jupiter.api.Assertions.*; /** * Tests {@code Dependency}. @@ -30,6 +29,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 +61,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()); + } } From ce14f6d5ad3d3d4956dbb4e696afce16fc4f13bb Mon Sep 17 00:00:00 2001 From: Yueh Chun Wu Date: Mon, 27 May 2024 18:37:47 -0700 Subject: [PATCH 5/5] Remove * from import statement --- .../src/test/java/org/apache/maven/model/DependencyTest.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 df8768664e15..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 @@ -21,7 +21,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +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}.