This is an automated email from the ASF dual-hosted git repository.
rfscholte 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 e64fd3b [MCOMPILER-398] Simplify the implementation of the
inclusion/exclusion logic
e64fd3b is described below
commit e64fd3b3ef93fc8831403cb9ca0147033bae12d6
Author: Russell Howe <[email protected]>
AuthorDate: Sat Sep 4 11:03:21 2021 +0200
[MCOMPILER-398] Simplify the implementation of the inclusion/exclusion logic
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.
Signed-off-by: rfscholte <[email protected]>
---
.../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()