ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Cuprak <507...@corpmail.kodak.com>
Subject Bug in Ant? Custom tasks aren't executed (set methods are called though) only when "antcall" is used.
Date Fri, 04 Oct 2002 18:04:41 GMT
Hello,
  I am having a problem with Ant that has me slightly baffled and very  
frustrated. It seems my custom ant tasks will not be run if they are  
inside an ant target called via "antcall". The set properties will  
however be called. For instance, in the code below, the setMessage and  
setFile methods on RCG task used in "utilities-build" will be called  
but the execute method will not if the target "test" is run (which  
makes an antcall to utilities-build). If "utilities-build" is directly  
executed, then the execute method of RCGenericLog will be run. I have  
confirmed this with other ant tasks I have written and been using.  
Note, using the "ant" tag to run a target in another file does not  
cause a problem- furthermore, targets run as a result of the "depends"  
attribute do not suffer this problem. So, what the heck is going on  
here - I'll look at the ant src next but has anyone run into ! this? It  
looks as if ant has been specifically coded to behave this way. Note,  
ONLY tasks that I write are affected by this - tasks that come with ant  
don't experience this.

 Ryan
   


   <target name="setup">
        <typedef name="RCGenericLog" classname="com.kodak.sis.ant.RCG"  
classpath="${g_ant_extensions}"/>
   </target>

    <target name="utilities-build" depends="setup">
        <RCGenericLog file="${generic.log}" message="-utilities-build-  
being run."> </RCGenericLog>
    </target>

    <target name="test" depends="setup">
        <antcall target="utilities-build">
    </target>

RCG.java ------------------------------------------------------------
package com.kodak.sis.ant;

import org.apache.tools.ant.Task;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;

import java.util.Date;
import java.util.List;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class RCG extends Task {

    private String m_file;
    private String m_message;

    public void setFile ( String file ) {
        log ( "setFile." );
        m_file = file;
    }

    public void setMessage ( String message ) {
        log ( "setMessage." );
        m_message = message;
    }


public void execute() throws BuildException {
        log (  
"----------------------------------------------------------------------- 
-----------------------------------executing." );
        System.exit(1);
        try {
            Project proj = getProject();
            String fo = proj.getBaseDir().getName() + File.separator +  
m_file;
            log ( "Generic Log: " + fo );
            File fot = new File(fo);
            if ( !fot.exists() )  {
                fot.createNewFile();
            }
            FileOutputStream fs = new FileOutputStream(fo,true);
            OutputStreamWriter out = new OutputStreamWriter(fs);
            out.write(m_message);
            out.close();
            fs.close();
        } catch (IOException e) {
            log ( e.toString() );
            throw new BuildException ( e );
        }

    }
}
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message