This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch maven-3.10.x
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 2271fbc738cce2baf390e6a6e0418574f56e40ee
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Fri Nov 27 13:52:54 2026 +0000

    Skip the pom artifact warning for POM files and test classifier artifacts
    
    A plugin may legitimately replace the project POM with a flattened or 
generated one.
---
 .../apache/maven/lifecycle/internal/MojoExecutor.java  | 10 +++++++++-
 .../internal/MojoExecutorPomArtifactWarningTest.java   | 18 ++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git 
a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
 
b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
index f9c6d0b657..da4e3867a2 100644
--- 
a/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
+++ 
b/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoExecutor.java
@@ -28,6 +28,7 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
@@ -378,7 +379,8 @@ static String pomArtifactFileWarning(MavenProject project, 
File artifactFileBefo
                 || (artifact.getClassifier() != null
                         && !artifact.getClassifier().isEmpty())
                 || artifact.getFile().equals(project.getFile())
-                || artifact.getFile().equals(artifactFileBefore)) {
+                || artifact.getFile().equals(artifactFileBefore)
+                || isPomFileName(artifact.getFile())) {
             return null;
         }
         return "Plugin " + mojoExecution.getPlugin().getId() + ":" + 
mojoExecution.getGoal() + " set the file of "
@@ -388,6 +390,12 @@ static String pomArtifactFileWarning(MavenProject project, 
File artifactFileBefo
                 + " attach it with a classifier instead.";
     }
 
+    /** A flattened or generated POM is a legitimate replacement for the 
project POM. */
+    private static boolean isPomFileName(File file) {
+        String name = file.getName().toLowerCase(Locale.ROOT);
+        return name.endsWith(".pom") || name.endsWith(".xml");
+    }
+
     public void ensureDependenciesAreResolved(
             MojoDescriptor mojoDescriptor, MavenSession session, 
DependencyContext dependencyContext)
             throws LifecycleExecutionException {
diff --git 
a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/MojoExecutorPomArtifactWarningTest.java
 
b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/MojoExecutorPomArtifactWarningTest.java
index 538a39721b..59da5a6443 100644
--- 
a/maven-core/src/test/java/org/apache/maven/lifecycle/internal/MojoExecutorPomArtifactWarningTest.java
+++ 
b/maven-core/src/test/java/org/apache/maven/lifecycle/internal/MojoExecutorPomArtifactWarningTest.java
@@ -74,6 +74,24 @@ void silentForLaterMojosOnceTheFileWasAlreadySet() {
         assertNull(MojoExecutor.pomArtifactFileWarning(project("pom", jar), 
jar, jarJar()));
     }
 
+    @Test
+    void silentWhenPomArtifactHasAnotherPomFile() {
+        assertNull(MojoExecutor.pomArtifactFileWarning(
+                project("pom", new File("target/.flattened-pom.xml")), null, 
jarJar()));
+        assertNull(
+                MojoExecutor.pomArtifactFileWarning(project("pom", new 
File("target/test-1.0.pom")), null, jarJar()));
+    }
+
+    @Test
+    void silentForClassifierArtifact() {
+        MavenProject project = project("pom", new 
File("target/test-1.0-sources.jar"));
+        DefaultArtifact sources = new DefaultArtifact(
+                "org.example", "test", "1.0", null, "pom", "sources", new 
DefaultArtifactHandler("pom"));
+        sources.setFile(new File("target/test-1.0-sources.jar"));
+        project.setArtifact(sources);
+        assertNull(MojoExecutor.pomArtifactFileWarning(project, null, 
jarJar()));
+    }
+
     private static MavenProject project(String extension, File artifactFile) {
         MavenProject project = new MavenProject();
         project.setGroupId("org.example");

Reply via email to