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

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

commit 0041bea00255fb47569c0c4628f0716269ce82ae
Author: Russell Howe <[email protected]>
AuthorDate: Sun Sep 22 09:40:26 2019 +0100

    [MCOMPILER-398] 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.
---
 .../apache/maven/plugin/compiler/CompilerMojo.java | 32 ++++++----------------
 1 file changed, 8 insertions(+), 24 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..6598253 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -361,46 +361,30 @@ public class CompilerMojo
     
     protected SourceInclusionScanner getSourceInclusionScanner( int 
staleMillis )
     {
-        SourceInclusionScanner scanner;
-
         if ( includes.isEmpty() && excludes.isEmpty() )
         {
-            scanner = new StaleSourceScanner( staleMillis );
+            return new StaleSourceScanner( staleMillis );
         }
-        else
+
+        if ( includes.isEmpty() )
         {
-            if ( includes.isEmpty() )
-            {
-                includes.add( "**/*.java" );
-            }
-            scanner = new StaleSourceScanner( staleMillis, includes, excludes 
);
+            includes.add( "**/*.java" );
         }
 
-        return scanner;
+        return new StaleSourceScanner( staleMillis, includes, excludes );
     }
 
     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()

Reply via email to