本文整理汇总了Java中org.codehaus.plexus.util.DirectoryScanner.addDefaultExcludes方法的典型用法代码示例。如果您正苦于以下问题:Java DirectoryScanner.addDefaultExcludes方法的具体用法?Java DirectoryScanner.addDefaultExcludes怎么用?Java DirectoryScanner.addDefaultExcludes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.plexus.util.DirectoryScanner
的用法示例。
在下文中一共展示了DirectoryScanner.addDefaultExcludes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: searchDir
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
private Stream<File> searchDir(File dir, boolean warnOnBadDir) {
if (dir == null || !dir.exists() || !dir.isDirectory()) {
if (warnOnBadDir && dir != null) {
getLog().warn("Directory does not exist or is not a directory: " + dir);
}
return Stream.empty();
}
getLog().debug("Adding directory " + dir);
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(dir);
ds.setIncludes(includes != null && includes.length > 0 ? includes : DEFAULT_INCLUDES);
ds.setExcludes(excludes);
ds.addDefaultExcludes();
ds.setCaseSensitive(false);
ds.setFollowSymlinks(false);
ds.scan();
return Stream.of(ds.getIncludedFiles()).map(filename -> new File(dir, filename)).parallel();
}
示例3: getFilesToCopy
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Returns a list of filenames that should be copied over to the destination directory.
*
* @param resource the resource to be scanned
* @return the array of filenames, relative to the sourceDir
*/
private String[] getFilesToCopy( Resource resource )
{
// CHECKSTYLE_OFF: LineLength
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( resource.getDirectory() );
if ( resource.getIncludes() != null && !resource.getIncludes().isEmpty() )
{
scanner.setIncludes( (String[]) resource.getIncludes().toArray( new String[resource.getIncludes().size()] ) );
}
else
{
scanner.setIncludes( DEFAULT_INCLUDES );
}
if ( resource.getExcludes() != null && !resource.getExcludes().isEmpty() )
{
scanner.setExcludes( (String[]) resource.getExcludes().toArray( new String[resource.getExcludes().size()] ) );
}
scanner.addDefaultExcludes();
scanner.scan();
return scanner.getIncludedFiles();
// CHECKSTYLE_ON: LineLength
}
示例4: getDirectoryFileNames
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Retrieves a list of file names that are in the given directory, possibly filtered by the list of include
* patterns or exclude patterns
*
* @param baseDirectory directory to retrieve file names from
* @param includes list of patterns to match against for file names to include, can include Ant patterns
* @param excludes list of patterns to match for excluded file names, can include Ant patterns
* @return list of file names within the directory that match all given patterns
*/
public static List<String> getDirectoryFileNames(File baseDirectory, String[] includes, String[] excludes) {
List<String> files = 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 includedFilename : scanner.getIncludedFiles()) {
files.add(includedFilename);
}
return files;
}
示例5: includesFiles
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
private String[] includesFiles(File baseDir, String[] excludes) {
DirectoryScanner dirScanner = new DirectoryScanner();
dirScanner.setBasedir(baseDir);
if (excludes != null) {
dirScanner.setExcludes(excludes);
}
dirScanner.addDefaultExcludes();
dirScanner.scan();
final String[] includedFiles = dirScanner.getIncludedFiles();
// ? dont know why we need this
for (int i = 0; i < includedFiles.length; i++) {
includedFiles[i] =
"/" + includedFiles[i].replace(File.separator, "/");
}
return includedFiles;
}
示例6: scanForSources
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Scans a single source dir for sources and includes only the files whose name match the patterns in
* sourceIncludes and excludes all files whose names match the patterns in sourceExcludes
* @param sourceDir The directory to scan
* @param sourceIncludes Only include a file if its name matches a pattern in sourceIncludes
* @param sourceExcludes Exclude a file if its name matches a pattern in sourceExcludes
* @return A set of filepath strings
*/
private static String[] scanForSources(final File sourceDir, final Set<String> sourceIncludes,
final Set<String> sourceExcludes) {
final DirectoryScanner ds = new DirectoryScanner();
ds.setFollowSymlinks( true );
ds.setBasedir( sourceDir );
ds.setIncludes(sourceIncludes.toArray(new String[sourceIncludes.size()]));
ds.setExcludes(sourceExcludes.toArray(new String[sourceExcludes.size()]));
ds.addDefaultExcludes();
try {
ds.scan();
} catch (IllegalStateException e) {
// the source directory (java/) does not exist
return new String[0];
}
return ds.getIncludedFiles();
}
示例7: getPackagesFromMainSources
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Gets the list of packages from {@literal src/main/java}. This method scans for ".class" files in {@literal
* target/classes}.
*
* @return the list of packages, empty if none.
*/
public Set<String> getPackagesFromMainSources() {
Set<String> packages = new LinkedHashSet<>();
File classes = getClassesDirectory();
if (classes.isDirectory()) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(classes);
scanner.setIncludes(new String[]{"**/*.class"});
scanner.addDefaultExcludes();
scanner.scan();
for (int i = 0; i < scanner.getIncludedFiles().length; i++) {
packages.add(Packages.getPackageName(scanner.getIncludedFiles()[i]));
}
}
return packages;
}
示例8: getPackagesFromTestSources
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Gets the list of packages from {@literal src/test/java}. This method scans for ".class" files in {@literal
* target/test-classes}.
*
* @return the list of packages, empty if none.
*/
public Set<String> getPackagesFromTestSources() {
Set<String> packages = new LinkedHashSet<>();
File classes = new File(basedir, "target/test-classes");
if (classes.isDirectory()) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(classes);
scanner.setIncludes(new String[]{"**/*.class"});
scanner.addDefaultExcludes();
scanner.scan();
for (int i = 0; i < scanner.getIncludedFiles().length; i++) {
packages.add(Packages.getPackageName(scanner.getIncludedFiles()[i]));
}
}
return packages;
}
示例9: getLocalResources
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Gets the list of resource files from {@literal src/main/resources} or {@literal src/test/resources}.
* This method scans for all files that are not classes from {@literal target/classes} or {@literal
* target/test-classes}. The distinction is made according to the value of {@code test}.
*
* @param test whether or not we analyse tests resources.
* @return the list of packages, empty if none.
*/
public Set<String> getLocalResources(boolean test) {
Set<String> resources = new LinkedHashSet<>();
File classes = getClassesDirectory();
if (test) {
classes = new File(basedir, "target/test-classes");
}
if (classes.isDirectory()) {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(classes);
scanner.setExcludes(new String[]{"**/*.class"});
scanner.addDefaultExcludes();
scanner.scan();
Collections.addAll(resources, scanner.getIncludedFiles());
}
return resources;
}
示例10: skip
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
@Override
public boolean skip(RunConfig config, boolean includingTests, long timeStamp) {
if (includingTests) {
if (!RunUtils.hasApplicationCompileOnSaveEnabled(config) && RunUtils.hasTestCompileOnSaveEnabled(config)) {
//in case when only tests are enabled for CoS, the main source root is not compiled on the fly.
// we need to checkif something was changed there and if so, recompile manually.
//TODO is there a way to figure if there is a modified java file in a simpler way?
File dirFile = FileUtilities.convertStringToFile(config.getMavenProject().getBuild().getSourceDirectory());
if (dirFile == null || !dirFile.exists()) { //#223461
return false;
}
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(dirFile);
//includes/excludes
ds.setIncludes(new String[]{"**/*.java"});
ds.addDefaultExcludes();
ds.scan();
String[] inclds = ds.getIncludedFiles();
for (String inc : inclds) {
File f = new File(dirFile, inc);
if (f.lastModified() >= timeStamp) {
return true;
}
}
}
}
return false;
}
示例11: hasChangedResources
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
private boolean hasChangedResources(Resource r, long stamp) {
String dir = r.getDirectory();
File dirFile = FileUtil.normalizeFile(new File(dir));
// System.out.println("checkresource dirfile =" + dirFile);
if (dirFile.exists()) {
List<File> toCopy = new ArrayList<File>();
DirectoryScanner ds = new DirectoryScanner();
ds.setBasedir(dirFile);
//includes/excludes
String[] incls = r.getIncludes().toArray(new String[0]);
if (incls.length > 0) {
ds.setIncludes(incls);
} else {
ds.setIncludes(DEFAULT_INCLUDES);
}
String[] excls = r.getExcludes().toArray(new String[0]);
if (excls.length > 0) {
ds.setExcludes(excls);
}
ds.addDefaultExcludes();
ds.scan();
String[] inclds = ds.getIncludedFiles();
// System.out.println("found=" + inclds.length);
for (String inc : inclds) {
File f = new File(dirFile, inc);
if (f.lastModified() >= stamp) {
toCopy.add(FileUtil.normalizeFile(f));
}
}
if (toCopy.size() > 0) {
//the case of filtering source roots, here we want to return false
//to skip CoS altogether.
return true;
}
}
return false;
}
示例12: getFilesToIncludes
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
/**
* Returns the file to copy. If the includes are <tt>null</tt> or empty, the default includes are used.
*
* @param baseDir the base directory to start from
* @param includes the includes
* @param excludes the excludes
* @param includeDirectories include directories yes or not.
* @return the files to copy
*/
// CHECKSTYLE_OFF: LineLength
protected PathSet getFilesToIncludes( File baseDir, String[] includes, String[] excludes, boolean includeDirectories )
// CHECKSTYLE_ON: LineLength
{
final DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir( baseDir );
if ( excludes != null )
{
scanner.setExcludes( excludes );
}
scanner.addDefaultExcludes();
if ( includes != null && includes.length > 0 )
{
scanner.setIncludes( includes );
}
else
{
scanner.setIncludes( DEFAULT_INCLUDES );
}
scanner.scan();
PathSet pathSet = new PathSet( scanner.getIncludedFiles() );
if ( includeDirectories )
{
pathSet.addAll( scanner.getIncludedDirectories() );
}
return pathSet;
}
示例13: getPropertyFileNamesToProcess
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
protected List<String> getPropertyFileNamesToProcess()
{
final List<String> propertyFileNames = new ArrayList<>();
final DirectoryScanner scanner = new DirectoryScanner();
scanner.setBasedir(this.sourceDirectory);
if (this.includes != null)
{
scanner.setIncludes(this.includes.toArray(new String[0]));
}
else
{
scanner.setIncludes(DEFAULT_INCLUDES.toArray(new String[0]));
}
if (this.excludes != null)
{
scanner.setExcludes(this.excludes.toArray(new String[0]));
}
scanner.addDefaultExcludes();
scanner.scan();
for (final String includedFile : scanner.getIncludedFiles())
{
propertyFileNames.add(includedFile);
}
return propertyFileNames;
}
示例14: 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;
}
示例15: getSourceFiles
import org.codehaus.plexus.util.DirectoryScanner; //导入方法依赖的package包/类
private List<File> getSourceFiles( List<File> sourceRootDirs )
{
List<File> sourceFiles = new ArrayList<File>();
Set<String> sourceIncludes = getSourceIncludes();
if ( sourceIncludes.isEmpty() )
{
sourceIncludes.add( "**/*.java" );
sourceIncludes.add( "**/*.scala" );
}
Set<String> sourceExcludes = getSourceExcludes();
DirectoryScanner scanner = new DirectoryScanner();
scanner.setIncludes( sourceIncludes.toArray( new String[sourceIncludes.size()] ) );
if ( !sourceExcludes.isEmpty() )
{
scanner.setExcludes( sourceExcludes.toArray( new String[sourceExcludes.size()] ) );
}
scanner.addDefaultExcludes();
for ( File dir : sourceRootDirs )
{
if ( dir.isDirectory() )
{
scanner.setBasedir( dir );
scanner.scan();
String[] includedFileNames = scanner.getIncludedFiles();
for ( String includedFileName : includedFileNames )
{
File tmpAbsFile = new File( dir, includedFileName ).getAbsoluteFile(); // ?
sourceFiles.add( tmpAbsFile );
}
}
}
// scalac is sensible to scala file order, file system can't guarantee file order => unreproductible build error
// across platform
// to guarantee reproductible command line we order file by path (os dependend).
// Collections.sort( sourceFiles );
return sourceFiles;
}
开发者ID:sbt-compiler-maven-plugin,项目名称:sbt-compiler-maven-plugin,代码行数:41,代码来源:AbstractSBTCompileMojo.java