ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jens Riboe <jens.ri...@ribomation.com>
Subject Redefinition of fileset
Date Wed, 28 Apr 2004 11:34:58 GMT
Hi,

I'm investigating how to use <typedef>, by redefining <fileset> and use in
in a context expecting an ordinary ditto. However, it doesn't work as 
expected.

Ant reports a redefinition
    Trying to override old definition of datatype fileset
But I cannot see any traceout of the new fileset implementation.

I'm using
    xyz> ant -version
    Apache Ant version 1.6.1 compiled on February 12 2004

Am I missing something or cannot I redefine fileset like the example below?

Many thanks in advance, for any light on this problem.
Cheers,
    Jens

---build.xml------------------------------------------------------
<target name="tst.fileset" depends="compile" >
        <typedef name="fileset" 
classname="com.ribomation.anttasks.dependencylist.MyFileSet">
            <classpath> <pathelement location="${class.dir}"/> </classpath>
        </typedef>

        <delete dir="${tmp.dir}" quiet="true" />
        <mkdir  dir="${tmp.dir}" />
        <mkdir  dir="${tmp.dir}/input" />
        <antcall target="mktmp">
            <param name="tmp.dir" value="${tmp.dir}/input"/>
        </antcall>
        <antcall target="mktmp">
            <param name="tmp.dir" value="${tmp.dir}/input"/>
        </antcall>

        <concat destfile="${tmp.dir}/RESULT.txt" append="true">
            <fileset dir="${tmp.dir}/input"/>
        </concat>
        <loadfile property="txt" srcFile="${tmp.dir}/RESULT.txt"/>
        <echo message="Content: [${txt}]"/>
    </target>

    <target name="mktmp">
        <tempfile property="tmpfile" destdir="${tmp.dir}" prefix="t"  
suffix=".txt"/>
        <echo message="Hello " file="${tmpfile}" />
    </target>
---------------------------------------------------------------

---OUTPUT------------------------------------------------------
xyz> ant tst.fileset
Buildfile: build.xml
init.props:
init.dirs:
init:
compile:
    [javac] Compiling 4 source files to C:\hack-cvs\DEPEND~1\target\classes
tst.fileset:
Trying to override old definition of datatype fileset
   [delete] Deleting directory C:\hack-cvs\DEPEND~1\target\tmp
    [mkdir] Created dir: C:\hack-cvs\DEPEND~1\target\tmp
    [mkdir] Created dir: C:\hack-cvs\DEPEND~1\target\tmp\input
mktmp:
mktmp:
     [echo] Content: [Hello Hello ]
BUILD SUCCESSFUL
Total time: 2 seconds
---------------------------------------------------------------

---MyFileSet------------------------------------------------------
public class MyFileSet extends FileSet {
    public DependencyFileSet() {
        this.getProject().log("[MyFileSet] init", Project.MSG_WARN);
    }
    public DirectoryScanner getDirectoryScanner(Project p) {
        this.getProject().log("[MyFileSet] getDirectoryScanner()", 
Project.MSG_WARN);
        return super.getDirectoryScanner(p);
    }
    public void setDir(File dir) throws BuildException {
        this.getProject().log("[MyFileSet] setDir("+dir+")", 
Project.MSG_WARN);
    }
}
---------------------------------------------------------------

Ant's own <concat> contains the following snippet
    for (Enumeration e = sources.elements(); e.hasMoreElements();) {
            Object o = e.nextElement();
            if (...} else if (o instanceof FileSet) {
                FileSet    fileSet = (FileSet) o;
                DirectoryScanner scanner =  
fileSet.getDirectoryScanner(getProject());
                checkAddFiles(fileSet.getDir(getProject()), 
scanner.getIncludedFiles());
            } else ...}
        }

I inserted a print statement into MyFileSet.getDirectoryScanner()
and expected to see
        [MyFileSet] getDirectoryScanner()"
in the OUTPUT.

The concat task contains this method for adding a FileSet.
    public void addFileset(FileSet set) {
        sources.addElement(set);
    }
I thought my own fileset would be substituted instead.




Mime
View raw message