ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject RE: Retrieving key value pairs from URL and setting as system property
Date Thu, 20 Mar 2008 09:28:46 GMT

-----Original Message-----
From: raju [mailto:raju_ak@hotmail.com] 
Sent: Thursday, March 20, 2008 6:16 AM
To: user@ant.apache.org
Subject: RE: Retrieving key value pairs from URL and setting as system
property

/*
This is what i am trying to acheive from within an Ant script:

Hit a URL say http://host/environment?name=test ,from which a get a
response
a containing key-value pairs containing data about the
environment.(could
this be done without writing the key-value data to a properties file by
just
reading response with Ant?)
*/

With vanilla ant and without scripting, you have to use 2 steps as
already
mentioned (see my first post and the post of Benjamin)

step1
use <get> contained in core ant
or
<httpget> from http://sourceforge.net/projects/fikin-ant-tasks

to get your content. Neither <get> nor <httpget> has a property
attribute,
means you can't redirect the content to a property straightforward.
But both have a dest / logFile attribute you can write the content to.

You may extend the task, implement that feature and send a patch to the
ant developer list ;-)

step2
load that file as propertyfile
<loadproperties srcFile="..." .../>

/*
Next step is to set the key value pairs obtained as system env variable
key=env variable name and value=env variable value so that next time
when i
run a command for ex: say wssmoke which needs these variables would pick
them up from environments variables rather than passing explicting to
the
command as parameters.
*/

So, you want dynamically overwrite existing env variables for your build
!?

1.
the propertyfile you'll loading later must use the same prefix you'll
use later
with <property environment="prefix" /> f.e. =

prefix.KEY0=foo
prefix.KEY1=bar
prefix.KEY2=foobar
prefix.KEY3=foobaz
...

2.
grap your file via <get> or <httpget>, write the the content to a file
as explained above (step1,step2)

3.
first load your propertyfile
<loadproperties srcFile="..." .../>
then
<property environment="prefix" />

when using that order, due to ant property immutability, prefix.KEY0
would be overwritten with the value of your propertyfiles if already
been set
But notice that the new prefix.KEY0 only exists for the lifecycle of
your build

Regards, Gilbert


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


Mime
View raw message