You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by "Brandon, Raymond" <Ra...@nl.compuware.com> on 2005/06/16 16:49:55 UTC

AbstractCvsTask not executing second command???

Hi all,

I am using some Ant functionality straight from Java and ran into problems:
The Cvs class (extending AbstractCvsTask) seems to work fine when called in
a build script when I call it directly from Java, the first time it works
ok, but any subsequent call to the execute method does not seem to return
any output from the CVS server. The program below illustrates the problem:
running it should cause 4 files to be created: ant_out1.log, ant_err1.log,
and_out2.log and ant_err2.log. Unfortunately only the first two files are
created in which the ant_out1.log contains the version info. This problem
even reproduces when I create a new instance of the CVS class but then it
still doesn't work. Can anybody help me out here? Debugging the code did not
give me the insight I needed obviously :)

Thanks in advance,

Raymond

public class TestAntCvs {
    public static void main(String[] args) {
        Cvs cvs = new Cvs();
        Project project = new Project();
        project.init();
        cvs.setProject(project);
        cvs.setCvsRoot(":pserver:cvs-user:cvs-user@<hostname
here>:2401:/Repository");
        cvs.setFailOnError(true);
        cvs.setCommand("version");
        cvs.setOutput(new File("c:\\temp\\ant_out1.log"));
        cvs.setError(new File("c:\\temp\\ant_err1.log"));
        cvs.execute(); // Works

        cvs.setCommand("version");
        cvs.setOutput(new File("c:\\temp\\ant_out2.log"));
        cvs.setError(new File("c:\\temp\\ant_err2.log"));
        cvs.execute(); // Does not do anything
    }
}


-- 
The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it. 


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


Re: AbstractCvsTask not executing second command???

Posted by Jeffrey E Care <ca...@us.ibm.com>.
> Well, actually, when they cannot be executed twice in a row, it often 
> means that they are buggy, because some instance variables modified by 
> the execution of the task are not reset to their value before the 
> execution of the task.

What about tasks that null out data members at the end of the execute 
method to release objects that are no longer needed (on the assumption 
that the task is one-time use only)?

My point was basically that certain tasks might support being reused, but 
as a general rule I wouldn't try it; I've seen many tasks that make the 
assumption that they will only be used once.

Bottom line - I would assume it's not safe to reuse a task unless I was 
certain that the task was coded in such a way to allow that type of usage.

JEC
-- 
Jeffrey E. Care (carej@us.ibm.com)
WebSphere Build SWAT Team Lead
WebSphere Build Tooling Lead (Project Mantis)
https://w3.opensource.ibm.com/projects/mantis

Re: AbstractCvsTask not executing second command???

Posted by Antoine Levy-Lambert <an...@antbuild.com>.
Jeffrey E Care wrote:
> Ant tasks are generally one-time use only.
> 
Well, actually, when they cannot be executed twice in a row, it often 
means that they are buggy, because some instance variables modified by 
the execution of the task are not reset to their value before the 
execution of the task.

@Brandon

In your particular case, since there is a special task called 
cvsversion, you might want to use it instead of using the generic cvs 
task with "version" as command.

Antoine


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


Re: AbstractCvsTask not executing second command???

Posted by Jeffrey E Care <ca...@us.ibm.com>.
Ant tasks are generally one-time use only.

-- 
Jeffrey E. Care (carej@us.ibm.com)
WebSphere Build SWAT Team Lead
WebSphere Build Tooling Lead (Project Mantis)
https://w3.opensource.ibm.com/projects/mantis


"Brandon, Raymond" <Ra...@nl.compuware.com> wrote on 06/16/2005 
10:49:55 AM:

> Hi all,
> 
> I am using some Ant functionality straight from Java and ran into 
problems:
> The Cvs class (extending AbstractCvsTask) seems to work fine when called 
in
> a build script when I call it directly from Java, the first time it 
works
> ok, but any subsequent call to the execute method does not seem to 
return
> any output from the CVS server. The program below illustrates the 
problem:
> running it should cause 4 files to be created: ant_out1.log, 
ant_err1.log,
> and_out2.log and ant_err2.log. Unfortunately only the first two files 
are
> created in which the ant_out1.log contains the version info. This 
problem
> even reproduces when I create a new instance of the CVS class but then 
it
> still doesn't work. Can anybody help me out here? Debugging the code did 
not
> give me the insight I needed obviously :)
> 
> Thanks in advance,
> 
> Raymond
> 
> public class TestAntCvs {
>     public static void main(String[] args) {
>         Cvs cvs = new Cvs();
>         Project project = new Project();
>         project.init();
>         cvs.setProject(project);
>         cvs.setCvsRoot(":pserver:cvs-user:cvs-user@<hostname
> here>:2401:/Repository");
>         cvs.setFailOnError(true);
>         cvs.setCommand("version");
>         cvs.setOutput(new File("c:\\temp\\ant_out1.log"));
>         cvs.setError(new File("c:\\temp\\ant_err1.log"));
>         cvs.execute(); // Works
> 
>         cvs.setCommand("version");
>         cvs.setOutput(new File("c:\\temp\\ant_out2.log"));
>         cvs.setError(new File("c:\\temp\\ant_err2.log"));
>         cvs.execute(); // Does not do anything
>     }
> }
> 
> 
> -- 
> The contents of this e-mail are intended for the named addressee only. 
It
> contains information that may be confidential. Unless you are the named
> addressee or an authorized designee, you may not copy or use it, or 
disclose
> it to anyone else. If you received it in error please notify us 
immediately
> and then destroy it. 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>