Skip to content

Instantly share code, notes, and snippets.

@rctay
Created August 4, 2011 18:22
Show Gist options
  • Save rctay/1125839 to your computer and use it in GitHub Desktop.
Save rctay/1125839 to your computer and use it in GitHub Desktop.
[ant] a tale of two Selectors
<copy todir="${temp_dir}/tinymce">
<fileset dir=".">
<include name="**"/>
<exclude name="**/.*/**"/>
<exclude name="**/.*"/>
<exclude name="build-utils/**" />
<!-- let the other FileSet take care of it -->
<exclude name="jscripts/tiny_mce/themes/advanced/js/*" />
</fileset>
<fileset dir=".">
<include name="jscripts/tiny_mce/themes/advanced/js/*.min.js" />
</fileset>
</copy>
<copy todir="${temp_dir}/tinymce">
<fileset dir=".">
<include name="**"/>
<exclude name="**/.*/**"/>
<exclude name="**/.*"/>
<exclude name="build-utils/**" />
<!-- let the other FileSet take care of it -->
<exclude name="jscripts/tiny_mce/themes/advanced/js/*" />
</fileset>
</copy>
<!-- we need a separate Copy task due to the Mapper -->
<copy todir="${temp_dir}/tinymce">
<!-- The Filename selector cannot see paths, so we need to set 'dir' specifically'... -->
<fileset dir="jscripts/tiny_mce/themes/advanced/js/">
<filename regex="(?&lt;=.min)\.js$" />
</fileset>
<!-- ...but this means we lose the leading path, which munges the Copy, so we need this Mapper to restore it. -->
<mapper type="glob" from="*" to="jscripts/tiny_mce/themes/advanced/js/*" />
</copy>

Description

These two Ant snippets do the same thing - include only *.min.js files in the 'themes/advanced/js/' directory. Yeah, I thought it would be as easy to get Ant to do this as it sounded, but as you can see, it doesn't seem so.

The first snippet would suffice for most, but I dreamt of a solution that uses PCRE lookbehinds; thus the second snippet was born. The Mapper and separate Copy task required seems dumb, though.

I wonder how one would do it with make...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment