You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Shylendran C <sh...@gmail.com> on 2009/03/12 07:38:15 UTC

Help... how to get a value from Java and pass it to another Target in ANT

Hi All,
Could you please help on this problem???

My requirement is
In my Java file, I have a method and it will return a value as String. I
have to get it from ANT script (build.xml) and after that I want to pass
this to another <target>

*See below code - build.xml*

    <target name="htmlCreation" depends="jar">
        <java jar="${jar.dir}/HtmlCreation.jar" fork="true"/>
    </target>

    <target name="main" depends="htmlCreation">
        <exec executable="${browser}" spawn="true">
        <arg value="HOW TO GET IT FROM JAVA"/>
        </exec>
    </target>


Thanks & Regards
Shylendran.C

Re: Help... how to get a value from Java and pass it to another Target in ANT

Posted by Joe Schmetzer <jo...@exubero.com>.
Hi Shylendran,

The <exec> task has the output and output outputproperty attributes. If
you get your Java program to write the data you need to stdout, the text
will appear there.

Alternatively, you could get your Java program to write a properties file
to the filesystem, and in then later use the Ant <property> task to pick
up the value that way.

Cheers,
Joe

On Thu, March 12, 2009 6:38 am, Shylendran C wrote:
> Hi All,
> Could you please help on this problem???
>
> My requirement is
> In my Java file, I have a method and it will return a value as String. I
> have to get it from ANT script (build.xml) and after that I want to pass
> this to another <target>
>
> *See below code - build.xml*
>
>     <target name="htmlCreation" depends="jar">
>         <java jar="${jar.dir}/HtmlCreation.jar" fork="true"/>
>     </target>
>
>     <target name="main" depends="htmlCreation">
>         <exec executable="${browser}" spawn="true">
>         <arg value="HOW TO GET IT FROM JAVA"/>
>         </exec>
>     </target>
>
>
> Thanks & Regards
> Shylendran.C



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