You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by eo...@apache.org on 2019/11/02 09:51:54 UTC

[maven-compiler-plugin] 01/01: [MCOMPILER-320] Introduce additionalClasspathElements property

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

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

commit 3b320687a4220f45654629f4416d926eccbd8088
Author: David M. Lloyd <da...@redhat.com>
AuthorDate: Wed Jan 17 12:04:04 2018 -0600

    [MCOMPILER-320] Introduce additionalClasspathElements property
---
 .../apache/maven/plugin/compiler/CompilerMojo.java | 17 +++++++++++--
 .../maven/plugin/compiler/TestCompilerMojo.java    | 29 +++++++++++++++++++---
 2 files changed, 40 insertions(+), 6 deletions(-)

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 78d3908..0f46c07 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -124,6 +124,14 @@ public class CompilerMojo
     @Parameter
     private boolean multiReleaseOutput;
 
+    /**
+     * A list of additional filesystem paths to include on the compile class path beyond the resolved dependency
+     * set.  This is useful in conjunction with the dependency plugin for cases where there are items that must not
+     * be included in other phases of the build, but are nevertheless required during compilation.
+     */
+    @Parameter
+    private List<String> additionalClasspathElements = new ArrayList<>();
+
     @Component
     private LocationManager locationManager;
 
@@ -275,7 +283,9 @@ public class CompilerMojo
                         }
                     }
                 }
-                
+
+                classpathElements.addAll( additionalClasspathElements );
+
                 for ( File file : resolvePathsResult.getModulepathElements().keySet() )
                 {
                     modulepathElements.add( file.getPath() );
@@ -292,7 +302,10 @@ public class CompilerMojo
         }
         else
         {
-            classpathElements = compilePath;
+            List<String> list = new ArrayList<>( compilePath.size() + additionalClasspathElements.size() );
+            list.addAll( compilePath );
+            list.addAll( additionalClasspathElements );
+            classpathElements = list;
             modulepathElements = Collections.emptyList();
         }
     }
diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
index 5b0518b..16cf038 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
@@ -163,6 +163,14 @@ public class TestCompilerMojo
     @Component
     private LocationManager locationManager;
 
+    /**
+     * A list of additional filesystem paths to include on the compile class path beyond the resolved dependency
+     * set.  This is useful in conjunction with the dependency plugin for cases where there are items that must not
+     * be included in other phases of the build, but are nevertheless required during compilation.
+     */
+    @Parameter
+    private List<String> additionalClasspathElements = new ArrayList<>();
+
     private Map<String, JavaModuleDescriptor> pathElements;
     
     private Collection<String> classpathElements;
@@ -306,7 +314,10 @@ public class TestCompilerMojo
             {
                 pathElements = Collections.emptyMap();
                 modulepathElements = Collections.emptyList();
-                classpathElements = testPath;
+                List<String> list = new ArrayList<>( testPath.size() + additionalClasspathElements.size() );
+                list.addAll( testPath );
+                list.addAll( additionalClasspathElements );
+                classpathElements = list;
                 return;
             }
         }
@@ -314,14 +325,17 @@ public class TestCompilerMojo
         {
             pathElements = Collections.emptyMap();
             modulepathElements = Collections.emptyList();
-            classpathElements = testPath;
+            List<String> list = new ArrayList<>( testPath.size() + additionalClasspathElements.size() );
+            list.addAll( testPath );
+            list.addAll( additionalClasspathElements );
+            classpathElements = list;
             return;
         }
             
         if ( testModuleDescriptor != null )
         {
             modulepathElements = testPath;
-            classpathElements = Collections.emptyList();
+            classpathElements = new ArrayList<>( additionalClasspathElements );
 
             if ( mainModuleDescriptor != null )
             {
@@ -392,6 +406,10 @@ public class TestCompilerMojo
                 {
                     patchModuleValue.append( root ).append( PS );
                 }
+                for ( String item : additionalClasspathElements )
+                {
+                    patchModuleValue.append( item ).append( PS );
+                }
                 
                 compilerArgs.add( patchModuleValue.toString() );
                 
@@ -401,7 +419,10 @@ public class TestCompilerMojo
             else
             {
                 modulepathElements = Collections.emptyList();
-                classpathElements = testPath;
+                List<String> list = new ArrayList<>( compilePath.size() + additionalClasspathElements.size() );
+                list.addAll( compilePath );
+                list.addAll( additionalClasspathElements );
+                classpathElements = list;
             }
         }
     }