當前位置: 首頁>>代碼示例>>Java>>正文


Java DirectoryScanner.setExcludes方法代碼示例

本文整理匯總了Java中org.codehaus.plexus.util.DirectoryScanner.setExcludes方法的典型用法代碼示例。如果您正苦於以下問題:Java DirectoryScanner.setExcludes方法的具體用法?Java DirectoryScanner.setExcludes怎麽用?Java DirectoryScanner.setExcludes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.codehaus.plexus.util.DirectoryScanner的用法示例。


在下文中一共展示了DirectoryScanner.setExcludes方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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();
}
 
開發者ID:revelc,項目名稱:impsort-maven-plugin,代碼行數:19,代碼來源:AbstractImpSortMojo.java

示例2: 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
}
 
開發者ID:zhegexiaohuozi,項目名稱:maven-seimicrawler-plugin,代碼行數:32,代碼來源:WarProjectPackagingTask.java

示例3: scanDirectory

import org.codehaus.plexus.util.DirectoryScanner; //導入方法依賴的package包/類
private void scanDirectory(File directory, BufferedWriter writer) throws IOException {
    if (!directory.exists())
        return;

    final Log log = getLog();
    log.info("scanning source directory '" + directory.getAbsolutePath() + "'");

    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setIncludes(includes);
    scanner.setExcludes(excludes);
    scanner.setBasedir(directory);
    scanner.scan();

    for (String fileName : scanner.getIncludedFiles()) {
        writer.write(fileName);
        writer.newLine();
    }
}
 
開發者ID:HostingAgency,項目名稱:gwtcoverage-maven-plugin,代碼行數:19,代碼來源:SourcesListMojo.java

示例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;
}
 
開發者ID:kuali,項目名稱:kc-rice,代碼行數:35,代碼來源:ThemeBuilderUtils.java

示例5: getClasses

import org.codehaus.plexus.util.DirectoryScanner; //導入方法依賴的package包/類
@Override
public List<String> getClasses() {
    DirectoryScanner classScanner = new DirectoryScanner();
    String baseDir = getClassDir();
    List<String> ret = new ArrayList<>();

    if(!new File(baseDir).exists()) {
        return ret;
    }
    classScanner.setBasedir(baseDir);
    classScanner.setCaseSensitive(true);
    classScanner.setIncludes(new String[]{"**/*class"});
    classScanner.setExcludes(new String[]{"**/*$*.class"});
    classScanner.scan();

    for(String s: classScanner.getIncludedFiles()){
        ret.add(s.replaceAll("/", ".").replaceAll("\\\\", ".").replaceAll("\\.class",""));
    }
    return ret;
}
 
開發者ID:spideruci,項目名稱:tacoco,代碼行數:21,代碼來源:GradleModule.java

示例6: getClasses

import org.codehaus.plexus.util.DirectoryScanner; //導入方法依賴的package包/類
@Override
public List<String> getClasses(){
	DirectoryScanner classScanner = new DirectoryScanner();
	String baseDir = new PathBuilder().path(targetDir).path("target").path("classes").buildFilePath();
	List<String> ret = new ArrayList<>();
	
	if(!new File(baseDir).exists()) {
		return ret;
	}
	classScanner.setBasedir(baseDir);
	classScanner.setCaseSensitive(true);
	classScanner.setIncludes(new String[]{"**/*class"});
	classScanner.setExcludes(new String[]{"**/*$*.class"});
	classScanner.scan();
	
	for(String s: classScanner.getIncludedFiles()){
		ret.add(s.replaceAll("/", ".").replaceAll("\\\\", ".").replaceAll("\\.class",""));
	}
	return ret;
	
}
 
開發者ID:spideruci,項目名稱:tacoco,代碼行數:22,代碼來源:MavenModule.java

示例7: scan

import org.codehaus.plexus.util.DirectoryScanner; //導入方法依賴的package包/類
/**
 * Scans a single directory
 *
 * @param root Directory to scan
 * @param includes
 * @param excludes
 * @return
 */
public static List<File> scan(File root, String[] includes, String[] excludes) {
	List<File> files = new ArrayList<File>();
	if (!root.exists()) {
		return files;
	}

	final DirectoryScanner directoryScanner = new DirectoryScanner();
	directoryScanner.setIncludes(includes);
	directoryScanner.setExcludes(excludes);
	directoryScanner.setBasedir(root);
	directoryScanner.scan();

	for (final String fileName : directoryScanner.getIncludedFiles()) {
		files.add(new File(root, fileName));
	}

	return files;
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:27,代碼來源:FileUtils.java

示例8: scanForJavaFiles

import org.codehaus.plexus.util.DirectoryScanner; //導入方法依賴的package包/類
private void scanForJavaFiles(List<SourceFile> sources, File sourceDirectory) {
	if (!sourceDirectory.exists()) {
		getLog().debug(sourceDirectory.getAbsolutePath() + " is declared but doesn't exist");
		return;
	}

	DirectoryScanner dirScanner = new DirectoryScanner();
	dirScanner.setBasedir(sourceDirectory);
	dirScanner.setIncludes(includes);
	dirScanner.setExcludes(excludes);
	dirScanner.scan();

	for (String includedPath : dirScanner.getIncludedFiles()) {
		if (includedPath.endsWith(".java")) {
			sources.add(new SourceFile(new File(sourceDirectory, includedPath)));
		}
	}
}
 
開發者ID:lgrignon,項目名稱:jsweet-maven-plugin,代碼行數:19,代碼來源:AbstractJSweetMojo.java

示例9: copyContent

import org.codehaus.plexus.util.DirectoryScanner; //導入方法依賴的package包/類
public static void copyContent( Path basePath, Path destPath, List<String> includes, List<String> excludes,
                                boolean filtering, Function<String, Object> mapper ) {
    DirectoryScanner scanner = new DirectoryScanner();
    scanner.setBasedir( basePath.toFile() );
    scanner.setIncludes( includes.toArray( new String[includes.size()] ) );
    scanner.setExcludes( excludes.toArray( new String[excludes.size()] ) );
    scanner.scan();
    for( String included : scanner.getIncludedFiles() ) {
        Path src = basePath.resolve( included );
        Path dst = destPath.resolve( included );
        if( filtering ) Files.writeString( dst, Strings.substitute( Files.readString( src ), mapper ) );
        else copy( src, Encoding.PLAIN, dst, Encoding.PLAIN );

        if( !Resources.IS_WINDOWS )
            setPosixPermissions( dst, getPosixPermissions( src ) );
    }
}
 
開發者ID:oaplatform,項目名稱:oap,代碼行數:18,代碼來源:Files.java

示例10: 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;
}
 
開發者ID:arquillian,項目名稱:arquillian-extension-liferay,代碼行數:23,代碼來源:LiferayWarPackagingProcessor.java

示例11: 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();
}
 
開發者ID:reprogrammer,項目名稱:checker-framework,代碼行數:29,代碼來源:PathUtils.java

示例12: collectFilesUsingGlobs

import org.codehaus.plexus.util.DirectoryScanner; //導入方法依賴的package包/類
/**
 * Collects files using globs if any
 * @param globs globs
 * @return list of files matching given globs
 */
private Collection<String> collectFilesUsingGlobs(List<String> globs) {
    if (globs == null || globs.isEmpty()) {
        return Collections.emptyList();
    }
    LOGGER.info("Collecting files using globs");
    final DirectoryScanner directoryScanner = new DirectoryScanner();
    String globsArray[] = new String[globs.size()];
    globs.toArray(globsArray);
    directoryScanner.setIncludes(globsArray);
    directoryScanner.setExcludes(new String[] {".gradle-srclib/**", ".m2-srclib/**"});
    directoryScanner.setBasedir(PathUtil.CWD.toString());
    directoryScanner.scan();
    Collection<String> files = new LinkedList<>();
    for (String fileName : directoryScanner.getIncludedFiles()) {
        files.add(PathUtil.concat(PathUtil.CWD, fileName).toString());
    }
    return files;
}
 
開發者ID:sourcegraph,項目名稱:srclib-java,代碼行數:24,代碼來源:GraphCommand.java

示例13: 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;
}
 
開發者ID:wisdom-framework,項目名稱:wisdom,代碼行數:27,代碼來源:ProjectScanner.java

示例14: 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;
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:FilteredResourcesCoSSkipper.java

示例15: 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;
}
 
開發者ID:zhegexiaohuozi,項目名稱:maven-seimicrawler-plugin,代碼行數:43,代碼來源:AbstractWarPackagingTask.java


注:本文中的org.codehaus.plexus.util.DirectoryScanner.setExcludes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。