You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2021/09/04 08:43:05 UTC

[maven-compiler-plugin] 01/02: Simplify logic around scanning for includes/excludes

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

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

commit f3252025970c345be8ac0e54f5136656b073d3ce
Author: Russell Howe <rh...@siksai.co.uk>
AuthorDate: Sun Sep 22 09:40:26 2019 +0100

    Simplify logic around scanning for includes/excludes
    
    The 'getSourceInclusionScanner' method can be simplified quite considerably.
    
    In the case where there are no includes or excludes, we can simply reuse the
    empty set of excludes we have rather than pulling an empty set out of
    Collections. This then makes both constructor calls to
    SimpleSourceInclusionScanner the same, so they can be merged.
    
    For the case where there are no includes, there are two paths. When there are
    also no excludes, we construct a singleton set of the default include pattern
    and assign it to includes. In the other case, where we have excludes but no
    includes, we add the defaultIncludePattern to the empty set of includes we
    have. These are equivalent operations, so merge them as well.
    
    i.e. have some default includes but allow this to be overridden and also allow
    excludes to be specified.
---
 .../org/apache/maven/plugin/compiler/CompilerMojo.java  | 17 +++--------------
 1 file changed, 3 insertions(+), 14 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 87f3bae..4df2dd0 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -381,26 +381,15 @@ public class CompilerMojo
 
     protected SourceInclusionScanner getSourceInclusionScanner( String inputFileEnding )
     {
-        SourceInclusionScanner scanner;
-
         // it's not defined if we get the ending with or without the dot '.'
         String defaultIncludePattern = "**/*" + ( inputFileEnding.startsWith( "." ) ? "" : "." ) + inputFileEnding;
 
-        if ( includes.isEmpty() && excludes.isEmpty() )
-        {
-            includes = Collections.singleton( defaultIncludePattern );
-            scanner = new SimpleSourceInclusionScanner( includes, Collections.<String>emptySet() );
-        }
-        else
+        if ( includes.isEmpty() )
         {
-            if ( includes.isEmpty() )
-            {
-                includes.add( defaultIncludePattern );
-            }
-            scanner = new SimpleSourceInclusionScanner( includes, excludes );
+            includes.add( defaultIncludePattern );
         }
 
-        return scanner;
+        return new SimpleSourceInclusionScanner( includes, excludes );
     }
 
     protected String getSource()