Ant pattern matching to select file is not working

2019-07-28 00:35发布

问题:

<fileset dir="${server.src}" casesensitive="yes">
  <patternset id="non.test.sources">
    <include name="**/test-[0-9-]+.zip"/>
  </patternset>
</fileset>

I am using pattern matching to select only particular file in ant build.xml But its not selecting any file. I have a file with name test-123453.zip

回答1:

A fileset's include element expects glob patterns, not regex patterns. Nesting it in a patternset doesn't change this functionality.

You can use the filename selector with the regex attribute to accomplish what you're trying to do:

<fileset dir="${server.src}">
    <filename regex="test-[0-9-]+\.zip" />
</fileset>


标签: regex build ant