ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Basel Ahmed <B06...@FDS.com>
Subject Unexpected behavior with <target unless="variable">
Date Wed, 25 Feb 2004 20:54:32 GMT
Hey all,

I'm seeing some unexpected behavior within the target unless option.

The troublesome script segment looks something like this:

<antcall target="target.name" />

<target name="target.name"
               depends="another.target"
               unless="some.condition" >

</target>


I have verified that the condition is set (echoing to the screen).

For some reason, Ant is executing that target and consequently its 
dependency
inspite of the true condition.  I'm using Ant 1.6.0.  Any ideas on what 
the real issue
might be?

Thanks

Basel Ahmed
Federated Systems Group
Site Build & Launch (Duluth)
basel.ahmed@fds.com

"If you think you can do a thing or think you can't do a thing, you're 
right." - Henry Ford (1863 - 1947)



"Hugo Costa" <hcosta@xlm.pt> 
02/25/2004 01:51 PM
Please respond to
"Ant Users List" <user@ant.apache.org>


To
"'Ant Users List'" <user@ant.apache.org>
cc

Subject
RE: Ant Api usage problems






Hi!

Thank you, for your help.
I got it to work partially...

My code is now this:

------------------------ FtpTest.java -------------------------------

import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.taskdefs.optional.net.FTP;
import org.apache.tools.ant.taskdefs.optional.net.FTP.Action;
import java.io.*;

public class FtpTest {

                 public static void main(String[] args){
 
                                 Project project = new Project();
                                 project.init();
                                 FileSet fileset = new FileSet();
                                 //fileset.setDir(new File(resourcesSrc));
                                 fileset.setIncludes(args[4]);
 
                                 FTP.Action ftpa = new FTP.Action();
                                 ftpa.setValue("get");
                                 FTP ftp=new FTP();
                                 ftp.setProject(project);
                                 ftp.setServer(args[0]);
                                 ftp.setUserid(args[1]);
                                 ftp.setPassword(args[2]);
                                 ftp.setRemotedir(args[3]);
                                 ftp.addFileset(fileset);
                                 ftp.setVerbose(true);
                                 ftp.setAction(ftpa);
                                 ftp.execute();
 
                 } 
}

----------------------------------------------------------------

But now it just hangs, it runs and stays there doing nada...
I can see in my linux logs that there is a connection to localhost.

This is during the execute method, I must have something wrong.
Can this be so hard to do? 

Do I have to use FTPClient class in conjunction to make this work?

Thank you. 

-----Original Message-----
From: Antoine Lévy-Lambert [mailto:antoine@antbuild.com] 
Sent: terça-feira, 24 de Fevereiro de 2004 21:39
To: Ant Users List
Subject: Re: Ant Api usage problems

Hugo Costa wrote:

>Hi,
>
>I'm having problems using some optional tasks of the Ant Api.
>The error is always the same, so i must be doing something wrong.
>I'm starting in java as well, as you can see...
>
>On example of what i'm doing is this, just trying to login to my own
>ftp. I'm on linux. I've tried with Scp and the result is the same.
>
>This builds correctly with ant.
>The error is always: java.lang.NullPointerException
>
>I've done another simple example of just making a directory and
>unzipping some files there with others ant task (Expand and mkDir),
>passing the name of the filezip and the name of the directory.
>
>So i don't understand what's wrong.
>
>I have the jars needed for both scp and ftp, i can use this tasks within
>a build.xml with no problems.
> 
>
I guess you get hit when ant tries to log.
do ftp.setProject(project);
before you start the execution, it should be better.
Also, I do not know why you make your class extend FTP, using it is good 
enough.

Antoine

here an example of ant api usage based on an existing build.xml file

public class testcvsversion {
    public static void main (String [] argv){
        Diagnostics.validateVersion();
        String filename="/dev/testant/cvsversion.xml";
        StringBuffer logBuffer;
        StringBuffer fullLogBuffer;
        Project project=new Project();
        logBuffer = new StringBuffer();
        fullLogBuffer = new StringBuffer();
        project = new Project();
        project.init();
        project.setUserProperty( "ant.file" , new 
File(filename).getAbsolutePath() );
        ProjectHelper.configureProject(project, new File(filename));
        project.addBuildListener(createLogger());
    }
    private static BuildLogger createLogger() {
        BuildLogger logger = null;
        logger = new DefaultLogger();
        logger.setMessageOutputLevel(Project.MSG_INFO);
        logger.setOutputPrintStream(System.out);
        logger.setErrorPrintStream(System.err);
        logger.setEmacsMode(false);

        return logger;
    }


>
>------------- Ftp.java -------------------------
>
>import org.apache.tools.ant.Project;
>import org.apache.tools.ant.Target;
>import org.apache.tools.ant.taskdefs.optional.net.FTP;
>import org.apache.tools.ant.BuildException;
>import java.io.File;
>
>public class Ftp extends FTP{
>
>                public static void FtpMkDir (String ftpServer, String 
userId, String
>userPassword, String remoteDir) {
>
>                                try {
>                                                Project project = new 
Project();
> 
> project.setName("testeftp");
>                                                project.init();
>
> System.out.println(ftpServer);
> System.out.println(userId);
> System.out.println(userPassword);
> System.out.println(remoteDir);
> 
>                                                FTP ftp = new FTP();
>                                                ftp.setServer(ftpServer);
>                                                ftp.setUserid(userId);
> ftp.setPassword(userPassword);
>                        //
> 
>
                                                    add here
 ftp.setProject(project);

>                                                System.out.println("Ponto 
5");
> 
>                                                ftp.execute();
>
>                                }
>                                catch (BuildException e) {
>                                                System.out.println("FTP 
Error: " + e);
>                                }
> 
>                }
> 
> 
>}
>
>
>
> 
>



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



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



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