ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dominique Devienne <DDevie...@lgc.com>
Subject RE: Poor support for selectors
Date Fri, 12 Mar 2004 14:53:56 GMT
> From: Jan.Materne@rzf.fin-nrw.de [mailto:Jan.Materne@rzf.fin-nrw.de]
> 
> I thought for myself to create a <scriptselector> where you simply
> implement the isSelected() method.
> 
> Base should be the BaseExtendSelector and the script gets
> basedir, filename and file (the arguments of isSelected()) as
> populated variables.
> 
> <fileset>
>     <scriptselector language="javascript">
>         return file.canWrite();
>     </scriptselector>
> </fileset>

I agree with Jan. I don't want to have build script littered with code.
<script>+BeanSehll power is awesome, but it's too verbose for my build.xml.

I would see a <script>-based selector extending DynamicConfigurator so I
can specify configuration arguments directory in the <script> tag, and
simply two nested tags, one optional for one time initialization, the other
required with the isSelected method.

To take Peter's example, I would envision:

<fileset dir=".">
  <scriptselector language="beanshell" pattern="^.*reg.*$"> 
    <init>
      _pattern = java.util.Pattern.compile(pattern);
      _matcher = _pattern.matcher("");
    </init>
    <isselected>
      return _matcher.reset(new java.io.File(filename).name).matches();
    <isselected>
  </scriptselector>
</fileset>

Or less performant, but less code:

<fileset dir=".">
  <scriptselector language="beanshell" pattern="^.*reg.*$"> 
    <isselected>
      return new java.io.File(filename).name.matches(pattern);
    <isselected>
  </scriptselector>
</fileset>

isselected automatically gets the basedir/filename/file names bound to the
method argument, and must be documented as such.

But I may be off base here ;-) --DD

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message