ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Cuprak <>
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
  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.


   <target name="setup">
        <typedef name="RCGenericLog" classname="com.kodak.sis.ant.RCG"  

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

    <target name="test" depends="setup">
        <antcall target="utilities-build">
    </target> ------------------------------------------------------------
package com.kodak.sis.ant;


import java.util.Date;
import java.util.List;

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." );
        try {
            Project proj = getProject();
            String fo = proj.getBaseDir().getName() + File.separator +  
            log ( "Generic Log: " + fo );
            File fot = new File(fo);
            if ( !fot.exists() )  {
            FileOutputStream fs = new FileOutputStream(fo,true);
            OutputStreamWriter out = new OutputStreamWriter(fs);
        } catch (IOException e) {
            log ( e.toString() );
            throw new BuildException ( e );

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