ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anderson, Rob (Global Trade)" <Rob.Ander...@nike.com>
Subject RE: Taskdef
Date Wed, 17 May 2006 18:47:56 GMT
I would not recommend this aproach. Write a build.xml.

-Rob A

> -----Original Message-----
> From: subir bhaumik [mailto:subir_05@yahoo.co.in] 
> Sent: Tuesday, May 16, 2006 10:39 PM
> To: Ant Users List
> Subject: RE: Taskdef
> 
> 
>   I am trying to write java code to use the
>   API rather than writing a build.xml.I am doing this for 
> testing purpose  so i have hardcoded. The following line in 
> the code throws  NullPointerException while executing the 
> code.The class_path is of type  Path.But while converting 
> class_path to String and printing that i get  a value.
>   
>   
>   tinstaller.setClasspath(class_path);
>   
>   
>   I am saying that the method  setClasspath of   
>   
>   
>   org.apache.tools.ant.taskdefs.Taskdef
>   
>   not getting the class_path
>   while the method setClasspath  of
>   
>   org.apache.tools.ant.taskdefs.Javac
>   
>   not throwing NullPointerException.
>   
>   Subir
>   
>   
> 
> "Anderson, Rob (Global Trade)" <Rob.Anderson@nike.com> wrote: 
>  I'm not sure what you are trying to do with this code, or 
> what the context is. Where are you wrong? To start with, you 
> have hardcoded a lot of things into your code. Are you trying 
> to write java code to use the API rather than writing a build.xml?
> 
> -Rob A
> 
> > -----Original Message-----
> > From: subir bhaumik [mailto:subir_05@yahoo.co.in]
> > Sent: Tuesday, May 16, 2006 6:44 AM
> > To: user@ant.apache.org
> > Subject: Taskdef
> > 
> > Hi
> >       While i am executing the following the   method  
> > setClasspath  of  Taskdef getting   NullPointerException, But 
> > the same  method for Javac is O.K.
> >   
> >   Where i am wrong?
> >   
> >   My Code
> >   
> >   
> >   
> >   String base_dir = Host.getBuildTemp();
> >   
> >               Project p = new Project();
> >               p.setName("Building");
> >               p.setDefault("installer") ;
> >               p.setBasedir(".");
> >              
> >                //org.apache.tools.ant.types.Reference
> > compile_class_path = new
> > org.apache.tools.ant.types.Reference(p,"compile_class_path");
> >              
> >                org.apache.tools.ant.types.Path class_path = new  
> > org.apache.tools.ant.types.Path(p);
> >              
> >                org.apache.tools.ant.types.FileSet fs = new 
> > org.apache.tools.ant.types.FileSet();
> >               File lib = new File(base_dir+"/"+"lib");
> >               fs.setDir(lib);
> >               fs.setIncludes("*.jar");
> >               class_path.addFileset(fs);
> >              
> >              
> >                org.apache.tools.ant.taskdefs.Taskdef
> > tinstaller = new  org.apache.tools.ant.taskdefs.Taskdef();
> >               tinstaller.setProject(p);
> >               tinstaller.setTaskName("izpack");
> >               String cp=class_path.toString();
> >               System.out.println("File Addition"+cp);
> >               tinstaller.setClasspath(class_path);
> > //NullPointerException
> >               System.out.println("File Test1");
> >               
> > tinstaller.setClassname("com.izforge.izpack.ant.IzPackTask");
> >               System.out.println("File Addition"+cp);
> >               IzPackTask izpack = new IzPackTask();
> >               System.out.println("File Test2");
> >               izpack.setInput("D:/subir/install.xml");
> >               izpack.setOutput("D:/subir/out.jar");
> >               System.out.println("Test3");
> >               izpack.setBasedir(".");
> >               Target installer = new Target();
> >               installer.setName("installer");
> >              
> >               installer.addTask(tinstaller);
> >               installer.addTask(izpack);
> >               //System.out.println(compile.toString());
> >                      
> >               p.addTarget(installer);
> >               DefaultLogger consoleLogger = new DefaultLogger();
> >               consoleLogger.setErrorPrintStream(System.err);
> >               consoleLogger.setOutputPrintStream(System.out);
> >               consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
> >               p.addBuildListener(consoleLogger);
> >              
> >   
> >   Warm Regards
> >   
> >   Subir
> >   
> >     
> > ---------------------------------
> >  Why was V. Sehwag warned by the BCCI? Share your knowledge 
> on Yahoo! 
> > Answers India  Send instant messages to your online friends - NOW
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For 
> additional commands, e-mail: user-help@ant.apache.org
> 
> 
> 
> 				
> ---------------------------------
>  Why was V. Sehwag warned by the BCCI? Share your knowledge 
> on Yahoo! Answers India  Send instant messages to your online 
> friends - NOW
> 


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


Mime
View raw message