private static void unzipExceptClasses(File archive, File destDir, Project prj) { Expand e = new Expand(); e.setProject(prj); e.setTaskType("unzip"); e.setSrc(archive); e.setDest(destDir); PatternSet p = new PatternSet(); p.setExcludes("WEB-INF/classes/"); e.addPatternset(p); e.execute(); }
/** * Add an inverted patternset. * @param p the pattern to invert and add. */ public void addConfiguredInvert(PatternSet p) { addConfiguredPatternset(new InvertedPatternSet(p)); } }
/** * This is a patternset nested element. * * @param p a configured patternset nested element. */ public void addConfiguredPatternset(PatternSet p) { if (isReference()) { throw noChildrenAllowed(); } String[] nestedIncludes = p.getIncludePatterns(getProject()); String[] nestedExcludes = p.getExcludePatterns(getProject()); if (nestedIncludes != null) { for (String nestedInclude : nestedIncludes) { createInclude().setName(nestedInclude); } } if (nestedExcludes != null) { for (String nestedExclude : nestedExcludes) { createExclude().setName(nestedExclude); } } }
/** * Returns the filtered include patterns. * @param p the current project. * @return the filtered excluded patterns. */ public String[] getExcludePatterns(Project p) { if (isReference()) { return getRef(p).getExcludePatterns(p); } dieOnCircularReference(p); readFiles(p); return makeArray(excludeList, p); }
/** * Returns the filtered include patterns. * @param p the current project. * @return the filtered included patterns. */ public String[] getIncludePatterns(Project p) { if (isReference()) { return getRef(p).getIncludePatterns(p); } dieOnCircularReference(p); readFiles(p); return makeArray(includeList, p); }
final PatternSet ps = new PatternSet(); ps.setProject(getProject()); if (packageNames.isEmpty()) { ps.createInclude().setName("**"); } else { packageNames.stream().map(PackageName::getName) .map(s -> s.replace('.', '/').replaceFirst("\\*$", "**")) .forEach(pkg -> ps.createInclude().setName(pkg)); .forEach(pkg -> ps.createExclude().setName(pkg)); ds.setDefaultexcludes(useDefaultExcludes); ds.setDir(dir); ds.createPatternSet().addConfiguredPatternset(ps); dirSets.add(ds); } else {
/** * Adds the patterns of the other instance to this set. * @param other the other PatternSet instance. * @param p the current project. */ public void append(PatternSet other, Project p) { if (isReference()) { throw new BuildException("Cannot append to a reference"); } dieOnCircularReference(p); String[] incl = other.getIncludePatterns(p); if (incl != null) { for (String include : incl) { createInclude().setName(include); } } String[] excl = other.getExcludePatterns(p); if (excl != null) { for (String exclude : excl) { createExclude().setName(exclude); } } }
PatternSet ps = new PatternSet(); if (!packageNames.isEmpty()) { for (String pn : packageNames) { pkg += "*"; ps.createExclude().setName(pkg); ds.setDefaultexcludes(useDefaultExcludes); ds.setDir(dir); ds.createPatternSet().addConfiguredPatternset(ps); dirSets.add(ds); } else {
private boolean hasPatterns(PatternSet ps) { String[] includePatterns = ps.getIncludePatterns(getProject()); String[] excludePatterns = ps.getExcludePatterns(getProject()); return (includePatterns != null && includePatterns.length > 0) || (includePatterns != null && excludePatterns.length > 0); }
/** 获取过滤输出文件的 {@link PatternSet} 对象 */ protected PatternSet getPatternSet() { PatternSet ps = null; if(includes != null || excludes != null) { ps = new PatternSet(); if(includes != null) ps.setIncludes(includes); if(excludes != null) ps.setExcludes(excludes); } return ps; }
/** * Creates a nested patternset. * @return <code>PatternSet</code>. */ public synchronized PatternSet createPatternSet() { if (isReference()) { throw noChildrenAllowed(); } PatternSet patterns = new PatternSet(); additionalPatterns.add(patterns); directoryScanner = null; return patterns; }
private PatternSet createPatternSet(Project prj) { PatternSet patternSet = new PatternSet(); patternSet.setProject(prj); patternSet.setIncludes("**/*"); return patternSet; }
/** * Get the merged patterns for this Files collection. * @param p Project instance. * @return the default patternset merged with the additional sets * in a new PatternSet instance. */ public synchronized PatternSet mergePatterns(Project p) { if (isReference()) { return getRef().mergePatterns(p); } dieOnCircularReference(); PatternSet ps = new PatternSet(); ps.append(defaultPatterns, p); additionalPatterns.forEach(pat -> ps.append(pat, p)); return ps; }
/** * Add a name entry to the include list. * @return <code>PatternSet.NameEntry</code>. */ public synchronized PatternSet.NameEntry createInclude() { if (isReference()) { throw noChildrenAllowed(); } ds = null; return defaultPatterns.createInclude(); }
/** * Add a name entry to the exclude list. * @return <code>PatternSet.NameEntry</code>. */ public synchronized PatternSet.NameEntry createExclude() { if (isReference()) { throw noChildrenAllowed(); } ds = null; return defaultPatterns.createExclude(); }
/** * Appends <code>includes</code> to the current list of include patterns. * Patterns may be separated by a comma or a space. * * @param includes the string containing the include patterns */ public void setIncludes(String includes) { if (isReference()) { throw tooManyAttributes(); } if (includes != null && !includes.isEmpty()) { StringTokenizer tok = new StringTokenizer(includes, ", ", false); while (tok.hasMoreTokens()) { createInclude().setName(tok.nextToken()); } } }
/** * Appends <code>excludes</code> to the current list of exclude patterns. * Patterns may be separated by a comma or a space. * * @param excludes the string containing the exclude patterns */ public void setExcludes(String excludes) { if (isReference()) { throw tooManyAttributes(); } if (excludes != null && !excludes.isEmpty()) { StringTokenizer tok = new StringTokenizer(excludes, ", ", false); while (tok.hasMoreTokens()) { createExclude().setName(tok.nextToken()); } } }
@Override public String[] getExcludePatterns(Project p) { return super.getIncludePatterns(p); } }
/** * Append <code>includes</code> to the current list of include * patterns. * * <p>Patterns may be separated by a comma or a space.</p> * * @param includes the <code>String</code> containing the include patterns. */ public synchronized void setIncludes(String includes) { checkAttributesAllowed(); defaultPatterns.setIncludes(includes); ds = null; }
@Override public String[] getIncludePatterns(Project p) { return super.getExcludePatterns(p); } @Override