-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
Hi,
I did a quick check of FileUtils::getFileAndDirectoryNames
Signature:
public static List<String> getFileAndDirectoryNames( File directory, String includes, String excludes,
boolean includeBasedir, boolean isCaseSensitive,
boolean getFiles, boolean getDirectories )
throws IOException;
Source:
plexus-utils/src/main/java/org/codehaus/plexus/util/FileUtils.java
Lines 1833 to 1906 in 1f93cc8
/** | |
* Return a list of files as String depending options. | |
* | |
* @param directory the directory to scan | |
* @param includes the includes pattern, comma separated | |
* @param excludes the excludes pattern, comma separated | |
* @param includeBasedir true to include the base dir in each String of file | |
* @param isCaseSensitive true if case sensitive | |
* @param getFiles true if get files | |
* @param getDirectories true if get directories | |
* @return a list of files as String | |
* @throws IOException io issue | |
*/ | |
public static List<String> getFileAndDirectoryNames( File directory, String includes, String excludes, | |
boolean includeBasedir, boolean isCaseSensitive, | |
boolean getFiles, boolean getDirectories ) | |
throws IOException | |
{ | |
DirectoryScanner scanner = new DirectoryScanner(); | |
scanner.setBasedir( directory ); | |
if ( includes != null ) | |
{ | |
scanner.setIncludes( StringUtils.split( includes, "," ) ); | |
} | |
if ( excludes != null ) | |
{ | |
scanner.setExcludes( StringUtils.split( excludes, "," ) ); | |
} | |
scanner.setCaseSensitive( isCaseSensitive ); | |
scanner.scan(); | |
List<String> list = new ArrayList<String>(); | |
if ( getFiles ) | |
{ | |
String[] files = scanner.getIncludedFiles(); | |
for ( String file : files ) | |
{ | |
if ( includeBasedir ) | |
{ | |
list.add( directory + FileUtils.FS + file ); | |
} | |
else | |
{ | |
list.add( file ); | |
} | |
} | |
} | |
if ( getDirectories ) | |
{ | |
String[] directories = scanner.getIncludedDirectories(); | |
for ( String directory1 : directories ) | |
{ | |
if ( includeBasedir ) | |
{ | |
list.add( directory + FileUtils.FS + directory1 ); | |
} | |
else | |
{ | |
list.add( directory1 ); | |
} | |
} | |
} | |
return list; | |
} |
It seems it can never throw an IOException.
If we removed it, a lot of Maven Mojos could be made MUCH simpler.
One of the reasons is that canGenerateReport
is called both in execute
and executeReport
. One throws a MojoExecutionException
, the other one a MavenReportException
, but canGenerateReport
can throw neither. This means, that it is impossible to deal with IOExceptions in Maven Reports anyway.
Metadata
Metadata
Assignees
Labels
No labels