Java Mailing List Archive

Apache Ant Archive

» Ant Users List
» Ant Developers List
How to make "outputproperty " element work???

How to make "outputproperty " element work???

2007-06-28       - By Ninju Bohra
Reply:     1     2     3     4     5     6     7     8     9     10     >>  


I made up the following quick test and the 'outputproperty' of the <java> task
worked just fine

Stupid JAVA class to generate the 'new' password and write the value to System
.out (so that it can be captured into the 'outputproperty')

public class GeneratePassword {
   public static void main(String[] args) {

I created the following property file to contain the current password text

Here is the quick build.xml with the target

<project name="test" default="convert_password">
<property name="prop_file" value=""/>
<target name="convert_password">
 <property file="${prop_file}"/>
 <echo> Current value of my_password is ${my_password}</echo>
 <java classname="GeneratePassword" outputproperty="new_password">
  <arg value="${my_password}"/>
             <pathelement path="."/>
 <echo>New password is ${new_password}</echo>
 <copy file="${prop_file}" tofile="new_${prop_file}"/>
 <replace file="new_${prop_file}" token="${my_password}" value="${new_password
 <echo>The new password is stored in the file called new_${prop_file}</echo>

And here is the output:

Buildfile: build.xml
    [echo]  Current value of my_password is Secret
    [echo] New password is SECRET
    [echo] The new password is stored in the file called
Total time: 0 seconds

In my example I wrote the 'updated' password into a copy of the of the original
file...if you want to overwrite the original value just skip the <copy> task
and adjust the "file" attribute in the <replace> task to match the orginial
file name

Hope that helps....


----- Original Message ----
From: broken connection <brokenconnection@(protected)>
To: user@(protected)
Sent: Wednesday, June 27, 2007 7:22:59 PM
Subject: How to make "outputproperty" element work???

Hi Friends,
I need some help with "outputproperty" element. I have a properties file, i
want to pass in one of the property to a java program and read the response
back and store it in the same property using ant for eg:


//I want to pass this to a java program and the property should be modified

I tried to use "JAVA" task but redirection was not working so I used this
"exec" task instead:

<filter filtersfile=""/>

<target name="test">
<exec executable="${ext}" resolveexecutable="true" os="Windows XP">
<arg value="/c"/>
<arg value="call-program.${ext} ${my_property}"/>
<redirector output=""
outputproperty="my_password" append="true" />

But its not working. I am able to redirect the output to some other file eg,
"xyz.txt" but then too the outputproperty element is not working,I want the
output as:

I have tried a lot, can somebody please give me a clue as to where i am
going wrong.I would really appreciate that.


Shape Yahoo! in your own image.  Join our Network Research Panel today!   http:

To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 - Jax Systems, LLC, U.S.A.