title: How do I use a patternset to filter a list of files?
body: <p>This seems like something that should be obvious, but I don't think it is.  Given:</p>
  
  <ul>
  <li>a space-delimited list of files (or comma-delimited, etc.)</li>
  <li>a <code>&lt;patternset&gt;</code> of whitelisted patterns</li>
  </ul>
  
  <p>How do I come up with a <code>&lt;fileset&gt;</code> that contains all of the files in the list that match the whitelisted pattern?</p>
  
  <p>Getting a list of files from the list is easy enough:</p>
  
  <pre>
  &lt;patternset id="the-patternset" includes="${list.of.files}" />
  &lt;fileset id="the-fileset" dir="${basedir}">
      &lt;patternset refid="the-patternset" />
  &lt;/fileset>
  &lt;pathconvert pathsep="${line.separator}" property="the-filelist" refid="the-fileset"/>
  &lt;echo>fileset: ${the-filelist}&lt;/echo>
  </pre>
  
  <p>…will happily produce a fileset with all of the files in <code>${list.of.files}</code>.  But adding a filter of sorts:</p>
  
  <pre>
  &lt;patternset id="the-filter">
      &lt;include name="includeme/**/*.java" />
      &lt;exclude name="excludeme/**/*.java" />
  &lt;/patternset>
  
  &lt;patternset id="the-patternset" includes="${list.of.files}" />
  &lt;fileset id="the-fileset" dir="${basedir}">
      &lt;patternset refid="the-patternset" />
      &lt;patternset refid="the-filter" />
  &lt;/fileset>
  &lt;pathconvert pathsep="${line.separator}" property="the-filelist" refid="the-fileset"/>
  &lt;echo>fileset: ${the-filelist}&lt;/echo>
  </pre>
  
  <p>…will list a union of the patternsets—i.e., all files that match either <code>the-filter</code> <em>or</em> <code>the-patternset</code>.</p>
  
  <p>How do I produce a fileset containing files that are in <code>${list.of.files}</code> <em>and</em> match <code>the-patternset</code>?</p>