Hi , 
        I used  " project.setproperty " as you suggested  and I get the
property value only at the default target or the first target am executing
in the project. If I have other targets in the project to be executed, The
property values are not available there . how can i resolve this ?
For clarity, I will type down my build file :


<project default="doNothing" basedir=".">
        <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>
        <property environment="env" />
        <target name="doLog" >
            <loadfile property="files" srcFile="RunFile.txt"/>
            <foreach target="generateLog" 
                     param="value" 
                     list="${files}" 
                     delimiter="${line.separator}" 
                     parallel="true"/>
             <foreach target="generateHtmlReport" 
                     param="value" 
                     list="${files}" 
                     delimiter="${line.separator}" 
                     parallel="true"/>
        </target>.....................

The property I set in the java code before running the buildfile is
available only at the target "doLog"(I echoed it to a file) .It is not
available in "generateLog" and "generateHtmlReport" targets .
Please help me .
Thanks 
Manju S Viswam


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 13, 2003 2:06 PM
To: [EMAIL PROTECTED]
Subject: RE: passing parameters to ant


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:[EMAIL PROTECTED]
> 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: [EMAIL PROTECTED] [ mailto:[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]> ]
> Sent: Wednesday, August 13, 2003 1:47 PM
> To: [EMAIL PROTECTED]
> 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.
> 
> **********************************************************************
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to