本文整理汇总了Java中org.codehaus.plexus.util.DirectoryScanner.getIncludedDirectories方法的典型用法代码示例。如果您正苦于以下问题:Java DirectoryScanner.getIncludedDirectories方法的具体用法?Java DirectoryScanner.getIncludedDirectories怎么用?Java DirectoryScanner.getIncludedDirectories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.DirectoryScanner
的用法示例。
在下文中一共展示了DirectoryScanner.getIncludedDirectories方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSassDirectories
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
private String[] getSassDirectories() {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(sassSourceDirectory);
scanner.setIncludes(new String[]{"**/sass"});
scanner.addDefaultExcludes();
scanner.scan();
return scanner.getIncludedDirectories();
}
示例2: getDirectoryContents
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Retrieves a list of files and directories that are in the given directory, possibly filtered by the
* list of include patterns or exclude patterns
*
* @param baseDirectory directory to retrieve files and directories from
* @param includes list of patterns to match against for files to include, can include Ant patterns
* @param excludes list of patterns to match for excluded files, can include Ant patterns
* @return list of files within the directory that match all given patterns
*/
public static List<String> getDirectoryContents(File baseDirectory, String[] includes, String[] excludes) {
List<String> contents = new ArrayList<String>();
DirectoryScanner scanner = new DirectoryScanner();
if (includes != null) {
scanner.setIncludes(includes);
}
if (excludes != null) {
scanner.setExcludes(excludes);
}
scanner.setCaseSensitive(false);
scanner.addDefaultExcludes();
scanner.setBasedir(baseDirectory);
scanner.scan();
for (String includedDirectory : scanner.getIncludedDirectories()) {
contents.add(includedDirectory);
}
for (String includedFilename : scanner.getIncludedFiles()) {
contents.add(includedFilename);
}
return contents;
}
示例3: copyDirectory
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Copies all the contents from the directory given by the source path to the directory given by the
* target path
*
* <p>
* If source directory does not exist nothing is performed. The target directory will be created if it
* does not exist. Any hidden directories (directory names that start with ".") will be deleted from the
* target directory
* </p>
*
* @param sourceDirectoryPath absolute path to the source directory
* @param targetDirectoryPath absolute path to the target directory
* @throws IOException
*/
public static void copyDirectory(String sourceDirectoryPath, String targetDirectoryPath)
throws IOException {
File sourceDir = new File(sourceDirectoryPath);
if (!sourceDir.exists()) {
return;
}
File targetDir = new File(targetDirectoryPath);
if (targetDir.exists()) {
// force removal so the copy starts clean
FileUtils.forceDelete(targetDir);
}
targetDir.mkdir();
FileUtils.copyDirectoryStructure(sourceDir, targetDir);
// remove hidden directories from the target
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(targetDir);
scanner.scan();
for (String includedDirectory : scanner.getIncludedDirectories()) {
File subdirectory = new File(targetDir, includedDirectory);
if (subdirectory.exists() && subdirectory.isDirectory()) {
if (subdirectory.getName().startsWith(".")) {
FileUtils.forceDelete(subdirectory);
}
}
}
}
示例4: cleanReports
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
private void cleanReports( File projectFile, String reportDirectory, String toolName, Log log )
throws MojoFailureException
{
final DirectoryScanner directoryScanner = new DirectoryScanner();
directoryScanner.setIncludes( new String[]{ "**\\" + reportDirectory } );
directoryScanner.setBasedir( projectFile.getParentFile() );
directoryScanner.scan();
log.info( "Cleaning up " + toolName + " reports" );
for ( String directoryName : directoryScanner.getIncludedDirectories() )
{
final File directory = new File( projectFile.getParentFile(), directoryName );
log.debug( "Deleting directory " + directory );
try
{
FileUtils.deleteDirectory( directory );
}
catch ( IOException ioe )
{
log.error( "Failed to delete directory " + directory );
throw new MojoFailureException( ioe.getMessage(), ioe );
}
}
log.info( toolName + " report clean-up complete" );
}