Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 2299 invoked from network); 24 Feb 2004 21:41:45 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 24 Feb 2004 21:41:45 -0000 Received: (qmail 53404 invoked by uid 500); 24 Feb 2004 21:41:13 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 53372 invoked by uid 500); 24 Feb 2004 21:41:12 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 53358 invoked from network); 24 Feb 2004 21:41:12 -0000 Received: from unknown (HELO relay.t-online-com.de) (62.156.147.74) by daedalus.apache.org with SMTP; 24 Feb 2004 21:41:12 -0000 Received: from antbuild.com (p5080e663.dip0.t-ipconnect.de [80.128.230.99]) by relay.t-online-com.de (SMTPSVC(1.0.0.2)) with ESMTP id E623314CACC for ; Tue, 24 Feb 2004 22:17:17 +0100 (CET) Message-ID: <403BC473.80703@antbuild.com> Date: Tue, 24 Feb 2004 22:38:59 +0100 From: =?ISO-8859-1?Q?Antoine_L=E9vy-Lambert?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Ant Users List Subject: Re: Ant Api usage problems References: <20040224134409.12512.qmail@web13426.mail.yahoo.com> <403B5893.8080705@corvil.com> <1077635589.3057.100.camel@jasao> In-Reply-To: <1077635589.3057.100.camel@jasao> X-Enigmail-Version: 0.82.4.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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