| How to make "outputproperty " element work??? | How to make "outputproperty " element work??? 2007-06-28 - By broken connection
Hi Ninju, I really really want to thank you for that great help. I almost spent 7 hours and was still trying to figure it out when your reply came.I tried everything from <antcontrib> to <replace> to <propertyset> and god knows what else....
And you made it sound soo easy...wow..you are genius man.
Thanks again for that great help...really appreciate it!!!!!
On 6/28/07, Ninju Bohra <ninju_bohra@(protected)> wrote: > > Hello, > > 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) { > System.out.println(args[0].toUpperCase()); > } > } > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > I created the following property file to contain the current password text > > value.properties: > my_password=Secret > > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- > Here is the quick build.xml with the target > > <project name="test" default="convert_password"> > <property name="prop_file" value="value.properties"/> > <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}"/> > <classpath> > <pathelement path="."/> > </classpath> > </java> > <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> > </target> > </project> > -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= > > And here is the output: > > C:\workspace\Test\bin>ant > Buildfile: build.xml > convert_password: > [echo] Current value of my_password is Secret > [echo] New password is SECRET > [echo] The new password is stored in the file called > new_value.properties > BUILD SUCCESSFUL > 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.... > > Ninju > > ----- 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: > > my_property=plain_password > > //I want to pass this to a java program and the property should be > modified > as: > my_property=encrypted_password > > I tried to use "JAVA" task but redirection was not working so I used this > "exec" task instead: > > <filter filtersfile="myfile.properties"/> > > <target name="test"> > <exec executable="${ext}" resolveexecutable="true" os="Windows XP"> > <arg value="/c"/> > <arg value="call-program.${ext} ${my_property}"/> > <redirector output="myfile.properties" > outputproperty="my_password" append="true" /> > </exec> > </target> > > 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: > property=value > > I have tried a lot, can somebody please give me a clue as to where i am > going wrong.I would really appreciate that. > > Cheers > > > > _______________________________________________________________________ _____________ > Shape Yahoo! in your own image. Join our Network Research Panel today! > http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@(protected) > For additional commands, e-mail: user-help@(protected) > >
|
|
 |