Ok,
an example!

you can do:
<project xmlns:ac="antlib:net.sf.antcontrib">
 <script language="beanshell">
   import java.io.File;
   import org.apache.tools.ant.types.selectors.FileSelector;
   public class NameSelector implements FileSelector {
       private String match;
       public void setMatch(String match) {
          this.match = match;
       }
       public boolean isSelected(File basedir, String filename, File file) {
          return new File(filename).name.matches(match);
       }
   }
   project.addDataTypeDefinition("selectname", NameSelector.class);
 </script>

<ac:for param="file">
<ac:path>
<ac:fileset dir=".">
<selectname match="^.*reg.*$"/>
</ac:fileset>
</ac:path>
<ac:sequential>
<echo>file is @{file}</echo>
</ac:sequential>
</ac:for> </project>


It would be a little easier using the proposed scripttypedef, but <script> works
fine as well.
Peter

Peter Reilly wrote:

If you use beanshell 2.0x (which you do!), you can use
a normal script task to create a selector.

Peter
Jose Alberto Fernandez wrote:

I need to construct a fileset using rules a little bit out of the
ordinary
and I an having a very hard time trying to do it in ANT.

What I need is to be able to match filenames using egexp rules for the
filename.
The only regexp things we have for selectors looks at the content of the
file,
and the only things to select of filenames, use ANT's filename
expressions.

We do not provide either a scriptselector (like we provide a script
filter)
neither.
Shall we try to close some of this gaps in 1.6.x? Or shall we wait for
1.7 and the new role based code.

I think one thing we should do in 1.7 is take a look at the all the core
features: filters, mappers, selectors, conditions, etc. And make sure we
provide simillar strength across the board (by prviding scriptXXX for
all) at a minimum.

Comments?

Jose Alberto





------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to