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

sjaranowski 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 d138bd4  [MCOMPILER-544] don't add items to classpath that are not 
used for that
d138bd4 is described below

commit d138bd4b6cd36d741d69887eeedb310c1655cea5
Author: Christoph Läubrich <[email protected]>
AuthorDate: Wed Sep 20 12:23:17 2023 +0200

    [MCOMPILER-544] don't add items to classpath that are not used for that
    
    Currently simply all kind of items are added to the classpath leading to
    strange errors in the ECJ compiler plugin because it does not know how
    to handle pom or other possible types.
    
    This adds an additional check to see if the artifact handler actually
    claims the itme should be put on the classpath,
---
 .../org/apache/maven/plugin/compiler/CompilerMojo.java     | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

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 2d3d4fa..023cec4 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -151,6 +151,7 @@ public class CompilerMojo extends AbstractCompilerMojo {
 
     private Map<String, JavaModuleDescriptor> pathElements;
 
+    @Override
     protected List<String> getCompileSourceRoots() {
         return compileSourceRoots;
     }
@@ -170,6 +171,7 @@ public class CompilerMojo extends AbstractCompilerMojo {
         return pathElements;
     }
 
+    @Override
     protected File getOutputDirectory() {
         File dir;
         if (!multiReleaseOutput) {
@@ -180,6 +182,7 @@ public class CompilerMojo extends AbstractCompilerMojo {
         return dir;
     }
 
+    @Override
     public void execute() throws MojoExecutionException, 
CompilationFailureException {
         if (skipMain) {
             getLog().info("Not compiling main sources");
@@ -344,11 +347,14 @@ public class CompilerMojo extends AbstractCompilerMojo {
         list.add(new File(project.getBuild().getOutputDirectory()));
 
         for (Artifact a : project.getArtifacts()) {
-            list.add(a.getFile());
+            if (a.getArtifactHandler().isAddedToClasspath()) {
+                list.add(a.getFile());
+            }
         }
         return list;
     }
 
+    @Override
     protected SourceInclusionScanner getSourceInclusionScanner(int 
staleMillis) {
         if (includes.isEmpty() && excludes.isEmpty() && 
incrementalExcludes.isEmpty()) {
             return new StaleSourceScanner(staleMillis);
@@ -363,6 +369,7 @@ public class CompilerMojo extends AbstractCompilerMojo {
         return new StaleSourceScanner(staleMillis, includes, excludesIncr);
     }
 
+    @Override
     protected SourceInclusionScanner getSourceInclusionScanner(String 
inputFileEnding) {
         // it's not defined if we get the ending with or without the dot '.'
         String defaultIncludePattern = "**/*" + 
(inputFileEnding.startsWith(".") ? "" : ".") + inputFileEnding;
@@ -375,10 +382,12 @@ public class CompilerMojo extends AbstractCompilerMojo {
         return new SimpleSourceInclusionScanner(includes, excludesIncr);
     }
 
+    @Override
     protected String getSource() {
         return source;
     }
 
+    @Override
     protected String getTarget() {
         return target;
     }
@@ -388,14 +397,17 @@ public class CompilerMojo extends AbstractCompilerMojo {
         return release;
     }
 
+    @Override
     protected String getCompilerArgument() {
         return compilerArgument;
     }
 
+    @Override
     protected Map<String, String> getCompilerArguments() {
         return compilerArguments;
     }
 
+    @Override
     protected File getGeneratedSourcesDirectory() {
         return generatedSourcesDirectory;
     }

Reply via email to