ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Atherton <br...@callenish.com>
Subject Re: Custom Selectors
Date Wed, 09 Apr 2008 23:57:50 GMT
The reason is that you have only defined your sets of directories. They 
aren't resolved until you use them. Try doing something with the dirset 
and see if you get your exception. I used:

<?xml version="1.0" ?>
<project name="anttest">
  <copy todir="/tmp" >
    <fileset dir="." >
        <custom classname="test.anttask.ContainsFileSelector" 
classpath="." >
          <param name="file" value="test.file"/>
        </custom>
    </fileset>
  </copy>
</project>

and got:

Buildfile: build.xml

BUILD FAILED
/sandbox/test/ant/build.xml:3: Yep, at least we're selecting

Total time: 0 seconds


Patrick Aikens wrote:
> I'm trying to write a custom selector.  It works fine, except that
> isSelected is never called.  This is using 1.6.5, with the .jar for
> the selector in ant's lib directory and the jar contains an
> antlib.xml.  Here's the pared down version.
> Yes, isSelected is set to throw an exception if it's ever called - I
> figure that's good enough until I can get it working.  The build file
> used below runs successfully.  I see the "Foop!test.file" when I run
> ant so it's instantiating my class and parsing the antlib just fine,
> but no exception is thrown.
>
> build file:
> -----------
> <?xml version="1.0" ?>
> <project name="anttest" xmlns:test="antlib:test.anttask">
>   <dirset dir="${basedir}">
>     <test:containsfile file="test.file"/>
>   </dirset>
> </project>
>
> Source:
> ----------
> package test.anttask;
>
> import java.io.File;
> import org.apache.tools.ant.BuildException;
> import org.apache.tools.ant.types.selectors.BaseExtendSelector;
>
> public class ContainsFileSelector extends BaseExtendSelector {
>     private String file;
>     public void setFile(String s) {
>         System.out.println("Foop!" + s);
>         file = s;
>     }
>
>     @Override
>     public boolean isSelected(File basedir, String filename, File
> checkFile) throws BuildException {
>         throw new BuildException("Yep, at least we're selecting");
>     }
> }
>
>
>   


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


Mime
View raw message