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

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 24c8104  [MCOMPILER-559] Warn if overwriting the project's artifact's 
file to a different value (#211)
24c8104 is described below

commit 24c81049c4fc11b5dabd2d1e0ce63331a86b9866
Author: Guillaume Nodet <gno...@gmail.com>
AuthorDate: Thu Nov 23 12:00:41 2023 +0100

    [MCOMPILER-559] Warn if overwriting the project's artifact's file to a 
different value (#211)
---
 src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java 
b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
index 41d6190..a364e91 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -28,6 +28,7 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Objects;
 import java.util.Set;
 
 import org.apache.maven.artifact.Artifact;
@@ -205,6 +206,10 @@ public class CompilerMojo extends AbstractCompilerMojo {
         super.execute();
 
         if (outputDirectory.isDirectory()) {
+            File artifactFile = projectArtifact.getFile();
+            if (artifactFile != null && !Objects.equals(artifactFile, 
outputDirectory)) {
+                getLog().warn("Overwriting artifact's file from " + 
artifactFile + " to " + outputDirectory);
+            }
             projectArtifact.setFile(outputDirectory);
         }
     }

Reply via email to