Hi,I guess you get hit when ant tries to log.
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.
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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]