I have a fileset (which is returned from the Maven Ant task), and it contains all the jars I need to repack. This fileset is referenced by a refid. I only want to include our own jars, so I would like to filter that. But Ant filesets don’t support any further attributes or nested tags if a refid is used.
For example, if the fileset is:
org.foo.1.jar org.foo.2.jar log4j.jar
and I want to have a fileset which contains only
org.foo*.jar
How would I do that?
Try using a
restrictresource collection, which you can use like afilesetin any task that uses resource collections to select the groups of files to operate on.For example, for a
filesetreturned from your Maven task referenced via an id calleddependency.filesetyou can declare arestrictresource collection like so:Note you’ll have to declare the resource selector namespace as it isn’t part of the built-in Ant namespace:
From here you can reference your
restrictresource collection in a similar fashion to how you would reference yourfileset. For example, to create backups of your filtered set of files:Of course you can inline your
restrictresource collection if you so desire:Have a look at the Ant documentation on resource collections for further information.