ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject RE: passing parameters to ant
Date Wed, 13 Aug 2003 08:36:12 GMT
So you want to set some ant properties.
Implement a setter in your RunningAnt . That method can execute Project´s
setProperty()-Method.

Project.java:
     * Sets a property. Any existing property of the same name
     * is overwritten, unless it is a user property.
     public void setProperty(String name, String value)


For setting targets:
    public void setDefaultTarget(String defaultTarget)
    public void addTarget(Target target) throws BuildException
    public void addTarget(String targetName, Target target) throws
BuildException
    ...


Jan



> -----Original Message-----
> From: Manju Sarala Viswam [mailto:mviswam@vanenburg.com]
> Sent: Wednesday, August 13, 2003 10:28 AM
> To: 'Ant Users List'
> Subject: RE: passing parameters to ant
> 
> 
> Hi ,
> I want to pass Parameters to a target in ant build file 
> .Target has a task
> like :
> <mkdir
> dir="${env.CORDYS_HOME}/Web/TestFramework/Log/${testcaseid}/${
> value}/${logva
> lue}"/>
> 
> Here , testcaseid ,value , logvalue are all parameters to be 
> accessed in
> this task.Till now, I have been writing all these values to a 
> text file from
> my Javacode and loading the textfile as a property in the 
> build file.But
> when multiple instances of my java program is running, 
> writing to a file is
> not reliable.SO I need a alternate solution by which I can 
> pass parameters .
> 
> Thanks & regards, 
> 
> Manju S Viswam
> 
> -----Original Message-----
> From: Jan.Materne@rzf.fin-nrw.de [ mailto:Jan.Materne@rzf.fin-nrw.de
> <mailto:Jan.Materne@rzf.fin-nrw.de> ]
> Sent: Wednesday, August 13, 2003 1:47 PM
> To: user@ant.apache.org
> Subject: RE: passing parameters to ant
> 
> 
> > Hi,
> >         I am using ant API and executing ant task from Java
> > as shown below.
> > I want to pass few parameters to ant build file.How do I do it ?
> 
> What kind of parameter?
> - Properties (like: -Dkey=value)
> - Targets    (like: ant build compile)
> - Options    (like: ant -diagnostics -version)
> 
> 
> 
> > public class RunningAnt extends Ant
> > {
> >         public RunningAnt(String buildFile) throws BuildException
> 
> I recommend renaming that parameter to buildDir. You don´t 
> set the buildFILE
> here...
> 
> 
> >         {
> >                 project = new Project();
> >                 project.init();
> >                 taskType = "ant";
> >               
> >                 taskName = "ant";
> >               
> >                 setDir(new File(buildFile));
> >                 setAntfile(buildFile+"\\build.xml");
> 
> Or better: use java.io.File for extracting the directory from 
> the buildfile
> and
> pass really the buildfile to RunningAnt.
> 
> 
> >
> >                 project.addBuildListener(new AntListener());
> >         }
> >
> >         public static void main (String []args){
> >               
> >                 RunningAnt Ra = new RunningAnt("D:\\rtf\\tests\\");
> >                 Ra.execute();
> >         }
> > }
> >
> > Thanks
> > Manju
> 
> 
> 
> Jan
> 
> 
> 
> 
> **********************************************************************
> The information in this message is confidential and may be legally
> privileged. It is intended solely for the addressee. Access 
> to this message
> by anyone else is unauthorized. If you are not the intended 
> recipient, any
> disclosure, copying, or distribution of the message, or any action or
> omission taken by you in reliance on it, is prohibited and 
> may be unlawful.
> Please immediately contact the sender if you have received 
> this message in
> error.
> 
> **********************************************************************
> 
> 

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