ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick Aikens" <paik...@gmail.com>
Subject Custom Selectors
Date Tue, 08 Apr 2008 21:27:52 GMT
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");
    }
}


-- 
SELECT * FROM users WHERE clue > 0

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


Mime
View raw message