org.apache.tools.ant.types.selectors.SelectorUtils Java Examples

The following examples show how to use org.apache.tools.ant.types.selectors.SelectorUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VerifyLibsAndLicenses.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void findStrayThirdPartyBinaries(File dir, String prefix, Set<String> violations, List<String> ignoredPatterns) throws IOException {
    for (String n : findHgControlledFiles(dir)) {
        File f = new File(dir, n);
        if (f.isDirectory()) {
            findStrayThirdPartyBinaries(f, prefix + n + "/", violations, ignoredPatterns);
        } else if (n.matches(".*\\.(jar|zip)")) {
            String path = prefix + n;
            boolean ignored = false;
            for (String pattern : ignoredPatterns) {
                if (SelectorUtils.matchPath(pattern, path)) {
                    ignored = true;
                    break;
                }
            }
            if (!ignored && dir.getName().equals("external") &&
                    new File(new File(dir.getParentFile(), "nbproject"), "project.xml").isFile()) {
                ignored = true;
            }
            if (!ignored) {
                violations.add(path);
            } else {
                //System.err.println("accepted: " + path);
            }
        }
    }
}
 
Example #2
Source File: DeleteUnreferencedClusterFiles.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void scanForExtraFiles(File d, String prefix, Set<String> files, String cluster, StringBuilder extraFiles) {
    if (prefix.equals("update_tracking/")) {
        return;
    }
    for (String n : d.list()) {
        File f = new File(d, n);
        if (f.getName().equals(".lastModified")) {
            continue;
        }
        if (f.isDirectory()) {
            scanForExtraFiles(f, prefix + n + "/", files, cluster, extraFiles);
        } else {
            String path = prefix + n;
            if ( patterns != null )
                for( String p: patterns.getExcludePatterns(getProject()) ) 
                    if (SelectorUtils.matchPath(p, path)) return;
                
            if (!files.contains(path)) {
                extraFiles.append("\n" + cluster + ": untracked file " + path);
                f.delete();
            }
        }
    }
}
 
Example #3
Source File: PatternMatchedFilter.java    From yGuard with MIT License 5 votes vote down vote up
protected boolean match( TypePatternSet.Type type, String str, PatternMatchedSection section ) {

    PatternSet patternSet = section.getPatternSet( type );

    if ( patternSet != null ) {

      String[] excludePatterns = patternSet.getExcludePatterns( project );
      if ( null != excludePatterns ) {
        for ( String excludePattern : excludePatterns ) {
          if ( SelectorUtils.match( excludePattern, str ) ) {
            return false;
          }
        }
      }

      String[] includePatterns = patternSet.getIncludePatterns( project );
      if ( null != includePatterns ) {
        for ( String includePattern : includePatterns ) {
          if ( SelectorUtils.match( includePattern, str ) ) {
            return true;
          }
        }
      } else {
        return true; // no include given: include all
      }
    } else {
      return true; // no patternset for type given: include all
    }
    return false; // str wasnt contained in includes / excludes
  }
 
Example #4
Source File: CodeGenerator.java    From avro-util with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private boolean isSharedSchema(String pathRelativeToRoot) {
    for (String importPattern : importablePatterns) {
        if (SelectorUtils.matchPath(importPattern, pathRelativeToRoot)) {
            return true;
        }
    }
    return false;
}
 
Example #5
Source File: CustomJavac.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static boolean isIgnored(
        final String[] patterns,
        final String resource) {
    for (String pattern : patterns) {
        if (SelectorUtils.match(pattern, resource)) {
            return true;
        }
    }
    return false;
}
 
Example #6
Source File: CreateLicenseSummary.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static boolean matchModule(Project project, PatternSet pattern, String module) {
    for (String p : pattern.getExcludePatterns(project)) {
        if (SelectorUtils.matchPath(p, module)) {
            return true;
        }
    }
    return false;
}
 
Example #7
Source File: Branding.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private boolean excluded(File f, String prefix) { // #68929
    String pathAbs = f.getAbsolutePath();
    if (!pathAbs.startsWith(prefix)) {
        throw new BuildException("Examined file " + f + " should have a path starting with " + prefix, getLocation());
    }
    // Cannot just call matchPath on the pathAbs because a relative pattern will *never* match an absolute path!
    String path = pathAbs.substring(prefix.length());
    for (String exclude : DirectoryScanner.getDefaultExcludes()) {
        if (SelectorUtils.matchPath(exclude.replace('/', File.separatorChar), path)) {
            return true;
        }
    }
    return false;
}
 
Example #8
Source File: ArtifactPlan.java    From gocd with Apache License 2.0 5 votes vote down vote up
protected String destinationURL(File rootPath, File file, String src, String dest) {
    String trimmedPattern = SelectorUtils.rtrimWildcardTokens(FilenameUtils.separatorsToUnix(src).replace('/', File.separatorChar));
    if (StringUtils.equals(FilenameUtils.separatorsToUnix(trimmedPattern), FilenameUtils.separatorsToUnix(src))) {
        return dest;
    }
    String trimmedPath = removeStart(subtractPath(rootPath, file), FilenameUtils.separatorsToUnix(trimmedPattern));
    if (!StringUtils.startsWith(trimmedPath, "/") && StringUtils.isNotEmpty(trimmedPath)) {
        trimmedPath = "/" + trimmedPath;
    }
    return dest + trimmedPath;
}
 
Example #9
Source File: UnZipStepExecution.java    From pipeline-utility-steps-plugin with MIT License 4 votes vote down vote up
boolean matches(String path, String glob) {
    String safeGlob = glob.replace('/', File.separatorChar);
    String safePath = path.replace('/', File.separatorChar);
    return SelectorUtils.matchPath(safeGlob, safePath);
}