com.atlassian.maven.plugin.clover.internal.scanner
Class AbstractSourceScanner

java.lang.Object
  extended by com.atlassian.maven.plugin.clover.internal.scanner.AbstractSourceScanner
All Implemented Interfaces:
CloverSourceScanner
Direct Known Subclasses:
MainSourceScanner, TestSourceScanner

public abstract class AbstractSourceScanner
extends Object
implements CloverSourceScanner

Code common to compute the list of source files to instrument (main sources, test sources) for Java and Groovy languages.


Constructor Summary
AbstractSourceScanner(CompilerConfiguration configuration, String outputSourceDirectory)
           
 
Method Summary
protected abstract  List<String> getCompileSourceRoots()
           
protected  CompilerConfiguration getConfiguration()
           
 Map<String,String[]> getExcludedFiles()
          Returns the list of excluded files that we'll need to copy.
protected abstract  String getSourceDirectory()
           
 Map<String,String[]> getSourceFilesToInstrument()
          Returns the list of source files to instrument taking into account the includes and excludes specified by the user.
 Map<String,String[]> getSourceFilesToInstrument(LanguageFileFilter languageFileFilter, boolean skipGroovySourceDirectory)
          This method can handle a special case: don't return excludes from native Groovy source directory (src/main/groovy or src/test/groovy) because such files shall not be copied to instrumented sources directory (target/clover/src-instrumented or target/clover/src-test/instrumented); a reason is that gmaven and groovy-eclipse-plugin have the src/xxx/groovy location hardcoded and they will compile this source root no matter what other compilation source roots or source directory are provided; it means that we would end up with a 'duplicate class' build error if files would be copied.
protected abstract  void removeGroovySourceRoot(Set<String> sourceRoots)
          From a list of provided sourceRoots remove those which specific for this scanner, unless the specific folder points to the same location as the getSourceDirectory().
protected  void removeSourceRoot(Set<String> sourceRoots, String sourceRootToRemove)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.maven.plugin.clover.internal.scanner.CloverSourceScanner
isSourceRootForLanguage
 

Constructor Detail

AbstractSourceScanner

public AbstractSourceScanner(@NotNull
                             CompilerConfiguration configuration,
                             @NotNull
                             String outputSourceDirectory)
Parameters:
configuration - compiler configuration
outputSourceDirectory - where to put instrumented sources
Method Detail

getExcludedFiles

public Map<String,String[]> getExcludedFiles()
Returns the list of excluded files that we'll need to copy. This is required as otherwise the excluded files won't be in the new Clover source directory and thus won't be compiled by the compile plugin. This will lead to compilation errors if any other Java file depends on any of them. The Map is indexed on source roots. This method handles a special case: don't return excludes from native Groovy source directory (src/main/groovy or src/test/groovy) because such files shall not be copied to instrumented sources directory (target/clover/src-instrumented or target/clover/src-test/instrumented); a reason is that gmaven-plugin and groovy-eclipse-plugin have the src/xxx/groovy location hardcoded and they will compile this source root no matter what other compilation source roots or source directory are provided; it means that we would end up with a 'duplicate class' build error if files are copied.

Specified by:
getExcludedFiles in interface CloverSourceScanner
Returns:
Map<String, String[]> = Map(source root, files)
See Also:
CloverSourceScanner.getExcludedFiles()

getSourceFilesToInstrument

public Map<String,String[]> getSourceFilesToInstrument()
Returns the list of source files to instrument taking into account the includes and excludes specified by the user. The Map is indexed on source roots.

Specified by:
getSourceFilesToInstrument in interface CloverSourceScanner
Returns:
Map<String, String[]> = Map(source root, files)
See Also:
CloverSourceScanner.getSourceFilesToInstrument()

getSourceFilesToInstrument

public Map<String,String[]> getSourceFilesToInstrument(LanguageFileFilter languageFileFilter,
                                                       boolean skipGroovySourceDirectory)
This method can handle a special case: don't return excludes from native Groovy source directory (src/main/groovy or src/test/groovy) because such files shall not be copied to instrumented sources directory (target/clover/src-instrumented or target/clover/src-test/instrumented); a reason is that gmaven and groovy-eclipse-plugin have the src/xxx/groovy location hardcoded and they will compile this source root no matter what other compilation source roots or source directory are provided; it means that we would end up with a 'duplicate class' build error if files would be copied. Please note however than in case when Groovy sources are located in a native Java source directory (src/main/java or src/test/java) then such files must be copied. A reason is that source roots will be redirected to the Clover's instrumented directory (target/clover/src-instrumented or target/clover/src-test/instrumented) and the groovy compiler must find both Java and Groovy files.

Specified by:
getSourceFilesToInstrument in interface CloverSourceScanner
Parameters:
languageFileFilter - extra filter (in addition to includes/excludes) based on the programming language
skipGroovySourceDirectory - if true then it will not return files located under Groovy source directory (i.e. 'src/main/groovy' or 'src/test/groovy')
Returns:
Map<File,String[]>

getCompileSourceRoots

protected abstract List<String> getCompileSourceRoots()

getSourceDirectory

protected abstract String getSourceDirectory()

getConfiguration

protected CompilerConfiguration getConfiguration()

removeGroovySourceRoot

protected abstract void removeGroovySourceRoot(@NotNull
                                               Set<String> sourceRoots)
From a list of provided sourceRoots remove those which specific for this scanner, unless the specific folder points to the same location as the getSourceDirectory().

Parameters:
sourceRoots - list to be modified
See Also:
getSourceFilesToInstrument()

removeSourceRoot

protected void removeSourceRoot(Set<String> sourceRoots,
                                String sourceRootToRemove)


Copyright © 2015 Atlassian Pty Ltd. All Rights Reserved.