hudson.plugins.pmd.util
Class ModuleDetector

java.lang.Object
  extended by hudson.plugins.pmd.util.ModuleDetector

public class ModuleDetector
extends java.lang.Object

Detects module names by parsing the name of a source file, the Maven pom.xml file or the ANT build.xml file.

Author:
Ulli Hafner

Field Summary
protected static java.lang.String ANT_PROJECT
          Filename of Ant project file.
protected static java.lang.String MAVEN_POM
          Filename of Maven pom.
 
Constructor Summary
ModuleDetector()
          Creates a new instance of ModuleDetector.
ModuleDetector(java.io.File workspace)
          Creates a new instance of ModuleDetector.
ModuleDetector(java.io.File workspace, FileInputStreamFactory fileInputStreamFactory)
          Creates a new instance of ModuleDetector.
 
Method Summary
protected  java.lang.String[] find(java.io.File path, java.lang.String pattern)
          Finds files of the matching pattern.
 java.lang.String guessModuleName(java.lang.String originalFileName)
          Uses the path prefixes of pom.xml or build.xml files to guess a module name for the specified file.
 java.lang.String guessModuleName(java.lang.String fileName, boolean isMavenBuild, boolean isAntBuild)
          Guesses a module name based on the source folder or the content in the pom.xml or build.xml files.
 void setFileInputStreamFactory(FileInputStreamFactory fileInputStreamFactory)
          Sets the factory to the specified value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAVEN_POM

protected static final java.lang.String MAVEN_POM
Filename of Maven pom.

See Also:
Constant Field Values

ANT_PROJECT

protected static final java.lang.String ANT_PROJECT
Filename of Ant project file.

See Also:
Constant Field Values
Constructor Detail

ModuleDetector

public ModuleDetector()
Creates a new instance of ModuleDetector.


ModuleDetector

public ModuleDetector(java.io.File workspace)
Creates a new instance of ModuleDetector.

Parameters:
workspace - the workspace to scan for maven pom.xml or ant build.xml files

ModuleDetector

public ModuleDetector(java.io.File workspace,
                      FileInputStreamFactory fileInputStreamFactory)
Creates a new instance of ModuleDetector.

Parameters:
workspace - the workspace to scan for maven pom.xml or ant build.xml files
fileInputStreamFactory - the value to set
Method Detail

setFileInputStreamFactory

public void setFileInputStreamFactory(FileInputStreamFactory fileInputStreamFactory)
Sets the factory to the specified value.

Parameters:
fileInputStreamFactory - the value to set

guessModuleName

public java.lang.String guessModuleName(java.lang.String originalFileName)
Uses the path prefixes of pom.xml or build.xml files to guess a module name for the specified file.

Parameters:
originalFileName - file name to guess a module for
Returns:
a module name or an empty string

find

protected java.lang.String[] find(java.io.File path,
                                  java.lang.String pattern)
Finds files of the matching pattern.

Parameters:
path - root path to scan in
pattern - pattern of files
Returns:
the found files

guessModuleName

public java.lang.String guessModuleName(java.lang.String fileName,
                                        boolean isMavenBuild,
                                        boolean isAntBuild)
Guesses a module name based on the source folder or the content in the pom.xml or build.xml files.

Parameters:
fileName - the absolute path of the file (UNIX style) to guess the module for
isMavenBuild - determines whether this build uses maven
isAntBuild - determines whether this build uses maven
Returns:
the guessed module name or an empty string if the name could not be resolved


Copyright © 2008. All Rights Reserved.