org.apache.tools.ant.types.PatternSet Java Examples

The following examples show how to use org.apache.tools.ant.types.PatternSet. 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: BundleLocator.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void createPatternSet()
{
  final PatternSet patternSet = new PatternSet();

  log("Creating a patternset for the bundles with id='" +patternSetId +"'.",
      Project.MSG_DEBUG);

  for (final Object element : bas.allBundleArchives) {
    final BundleArchives.BundleArchive ba
      = (BundleArchives.BundleArchive) element;

    patternSet.setIncludes(ba.relPath);
    log("Adding includes '" +ba.relPath +"'.", Project.MSG_DEBUG);
  }
  getProject().addReference(patternSetId, patternSet);
}
 
Example #2
Source File: JarExpander.java    From PoseidonX with Apache License 2.0 5 votes vote down vote up
private PatternSet createPatternSet(Project prj)
{
    PatternSet patternSet = new PatternSet();
    patternSet.setProject(prj);
    patternSet.setIncludes("**/*");
    return patternSet;
}
 
Example #3
Source File: JarBundler.java    From JarBundler with Apache License 2.0 5 votes vote down vote up
/**
 * Setter for the "extraclasspath" attribute (optional)
 * 
 * @param s A list of files or patternsets (space or comma seperated)
 */
public void setExtraclasspath(String s) {
	if (s == null || s.trim().equals("")) return;
	PatternSet patset = new PatternSet();
	patset.setIncludes(s);

	String[] cpNames = patset.getIncludePatterns(getProject());

	for (int i = 0; i < cpNames.length; i++) {
		File f = new File(cpNames[i]);
		mExtraClassPathAttrs.add(f);
	}
}
 
Example #4
Source File: JarBundler.java    From JarBundler with Apache License 2.0 5 votes vote down vote up
/**
 * Setter for the "execs" attribute
 * 
 * @deprecated Use &lt;execfileset/&gt; or &lt;execfilelist/&gt; nested tasks instead.
 * 
 * @param s A list of files or patternsets (space or comma seperated)
 */
public void setExecs(String s) {
	PatternSet patset = new PatternSet();
	patset.setIncludes(s);

	String[] execNames = patset.getIncludePatterns(getProject());

	for (int i = 0; i < execNames.length; i++) {
		File f = new File(execNames[i]);
		mExecAttrs.add(f);
	}
}
 
Example #5
Source File: JarBundler.java    From JarBundler with Apache License 2.0 5 votes vote down vote up
/**
 * Setter for the "jars" attribute (required if no "jarfileset" is present)
 * 
 * @deprecated Use &lt;jarfileset&gt; and/or &lt;jarfilelist&gt; nested tasks instead. 
 * 
 * @param s A list of jar files or patternsets (space or comma seperated)
 */
public void setJars(String s) {
	PatternSet patset = new PatternSet();
	patset.setIncludes(s);

	String[] jarNames = patset.getIncludePatterns(getProject());

	for (int i = 0; i < jarNames.length; i++)
		mJarAttrs.add(getProject().resolveFile(jarNames[i]));
}
 
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: LocFiles.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String fixJarName(String prefixDir, String name) {
    if (prefixDir.endsWith("locale/") && baseFiles != null) {
        prefixDir = prefixDir.substring(0, prefixDir.length() - 7);
        PatternSet bf = (PatternSet)getProject().getReference(baseFiles);
        for (String p : bf.getIncludePatterns(getProject())) {
            if (p.startsWith(prefixDir)) {
                String realName = p.substring(prefixDir.length());
                if (realName.indexOf('/') != -1 || realName.indexOf('\\') != -1) {
                    continue;
                }
                int indx = realName.indexOf(name);
                if (indx == -1) {
                    continue;
                }
                return realName.substring(0, indx + name.length());
            }
        }
    }
    
    
    if (name.equals("autoupdate-ui_nb")) {
        return "org-netbeans-modules-autoupdate-ui_nb";
    }
    if (name.equals("options-api_nb")) {
        return "org-netbeans-modules-options-api_nb";
    }
    if (name.equals("uihandler_nb")) {
        return "org-netbeans-modules-uihandler_nb";
    }
    return name;
}
 
Example #8
Source File: LocFiles.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void execute() throws BuildException {
    List<String> includes = new ArrayList<>();
    if (locales != null && !locales.isEmpty()) {
        if (!srcDir.exists()) {
            log("No l10n files present. Do hg clone http://hg.netbeans.org/main/l10n!", Project.MSG_VERBOSE);
            return;
        }

        StringTokenizer tok = new StringTokenizer(locales, ",");
        while (tok.hasMoreElements()) {
            String locale = tok.nextToken();
            if (locale.equals("default")) { // NOI18N
                locale = Locale.getDefault().toString();
            }
            for (String l = locale; l != null; l = trailingUnderscore(l)) {
                processLocale(l, includes, l.equals(locale));
            }
        }
    }
    
    if (patternset != null) {
        PatternSet ps = new PatternSet();
        ps.setProject(getProject());
        if (includes.isEmpty()) {
            ps.createInclude().setName("I/dont/exist/at/all");
        } else {
            for (String s : includes) {
                ps.createInclude().setName(s);
            }
        }
        getProject().addReference(patternset, ps);
    }
    
}
 
Example #9
Source File: LocFilesTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void assertPattern(String cluster, String file) {
    Object ref = task.getProject().getReference("pattern.set");
    assertNotNull("Reference is found", ref);
    assertTrue("Right instance: " + ref, ref instanceof PatternSet);
    PatternSet ps = (PatternSet)ref;
    
    List<String> arr = Arrays.asList(ps.getIncludePatterns(task.getProject()));
    assertTrue(file + " is there: " + arr, arr.contains(file));
}
 
Example #10
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 #11
Source File: JarExpander.java    From PoseidonX with Apache License 2.0 5 votes vote down vote up
private Expand createExpand(File jarFile)
{
    String outputDir = expandDir + File.separator + jarFile.getName();

    Project prj = new Project();
    FileSet fileSet = createFileSetForJarFile(jarFile, prj);
    PatternSet patternSet = createPatternSet(prj);
    Expand expand = new Expand();
    expand.setProject(prj);
    expand.setOverwrite(true);
    expand.setDest(new File(outputDir));
    expand.addFileset(fileSet);
    expand.addPatternset(patternSet);
    return expand;
}
 
Example #12
Source File: PatternMatchedSection.java    From yGuard with MIT License 5 votes vote down vote up
public PatternSet getPatternSet( TypePatternSet.Type type ) {
  if ( null != patternSets ) {
    return patternSets.get( type );
  } else {
    return null;
  }
}
 
Example #13
Source File: PatternMatchedSection.java    From yGuard with MIT License 5 votes vote down vote up
public void addPatternSet( final PatternSet ps, TypePatternSet.Type type ) {
  if ( null == patternSets ) {
    patternSets = new EnumMap<TypePatternSet.Type, PatternSet>( TypePatternSet.Type.class );
  }

  // merge patternsets of same type
  if ( null != patternSets.get( type ) ) {
    PatternSet existing = patternSets.get( type );
    ps.addConfiguredPatternset( existing );
  }
  patternSets.put( type, ps );
}
 
Example #14
Source File: ObfuscatorTask.java    From yGuard with MIT License 5 votes vote down vote up
public void addAttributesSections( List<AttributesSection> attributesSections ) {
  if ( null != expose ) {
    List attributes = expose.getAttributes();
    for ( AttributesSection attributesSection : attributesSections ) {
      com.yworks.yguard.ant.AttributesSection asYGuard = new com.yworks.yguard.ant.AttributesSection( this );
      PatternSet patternSet = attributesSection.getPatternSet(TypePatternSet.Type.NAME);
      if (patternSet != null) {
        asYGuard.addConfiguredPatternSet( patternSet );
      }
      asYGuard.setName( attributesSection.getAttributesStr() );
      attributes.add( asYGuard );
    }
  }
}
 
Example #15
Source File: ClassSection.java    From yGuard with MIT License 5 votes vote down vote up
public void addEntries( Collection entries, ZipFileSet zf ) throws IOException {
  if ( classesSet && patternSets.size() < 1 ) {
    PatternSet ps = new PatternSet();
    ps.setProject( zf.getProject() );
    ps.setIncludes( "**.*" );
    patternSets.add( ps );
  }
  super.addEntries( entries, zf );
}
 
Example #16
Source File: YShrinkInvokerImpl.java    From yGuard with MIT License 5 votes vote down vote up
private void addPatternSets( PatternMatchedClassesSection yGuardSection,
                             com.yworks.yguard.common.ant.PatternMatchedSection yShrinkSection, String type ) {
  if ( null != yGuardSection.getPatternSets() ) {
    for ( PatternSet ps : (Iterable<? extends PatternSet>) yGuardSection.getPatternSets() ) {
      TypePatternSet tps = new TypePatternSet();
      tps.append( ps, shrinkTask.getProject() );
      tps.setType( type );
      yShrinkSection.addPatternSet( tps, tps.getType() );
    }
  }
}
 
Example #17
Source File: CreateLicenseSummary.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void setExcludes(String str) {
    excludeFiles = new PatternSet();
    excludeFiles.setExcludes(str);
}
 
Example #18
Source File: DeleteUnreferencedClusterFiles.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Option to remove files from those checks
 */
public void addConfiguredSelection(PatternSet p) {
    patterns = p;
}
 
Example #19
Source File: PackageSection.java    From yGuard with MIT License 4 votes vote down vote up
public void addConfiguredPatternSet(PatternSet ps) {
  patternSets.add(ps);
}
 
Example #20
Source File: PatternMatchedClassesSection.java    From yGuard with MIT License 4 votes vote down vote up
public void addConfiguredPatternSet( PatternSet ps){
  patternSets.add(ps);
}
 
Example #21
Source File: ExposeSection.java    From yGuard with MIT License 4 votes vote down vote up
public void addPatternSet( PatternSet ps ) {
  patterns.add( ps );
}