You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Dominique Devienne <DD...@lgc.com> on 2004/01/18 19:49:18 UTC

RE: Including the value of properties defined in a build.xml in s ource files such as web.xml?

> From: Adrian Beech [mailto:a.beech@bigpond.net.au]
> 
> G'day,
> 
> I was wondering if it is possible to include the value of properties
> defined in the build.xml file in source files such as web.xml?  I have
> three staging environments which have platform specific attributes such
> as JDBC connections strings, application headers, etc.  These values are
> defined in the web.xml file and it would make life a whole lot easier if
> they could be defined as properties in the build.xml file and
> substituted in the right places within the source files when the
> appropriate target is specified.
> 
> One of the annoying things I need to do each time I progress an
> application from one environment to another is to remember to edit the
> web.xml file so that the resulting package has the appropriate
> application/environment attributes.  Things would be a hole lot nicer if
> I could simply type "ant dev", "ant test" or "ant prod" and have
> everything set up accordingly.
> 
> I would appreciate any help in this matter.

Two distinct approaches:

(1) Use Ant-like properties in the web.xml files (of the form ${name}),
    and use the <replaceproperties> Filter. Your web.xml files thus act
    as templates, and your <copy> (+filter) the actual files to use at
    runtime.

(2) Extract the values from the web.xml files, and use them in Ant.
    This is IMHO more difficult/cumbersome. You might get be able to
    to use <xmlproperty>, the JXPATH-based custom Property Helper
    defined somewhere by Nicola Ken Barrozi, or finally XSL your
    web.xml files into a property file your load, or a build file
    you import in the main build file.

I'd go with (1) myself, but I don't know of your specifics. --DD

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


RE: Including the value of properties defined in a build.xml in source files such as web.xml?

Posted by Matt Raible <li...@raibledesigns.com>.
 
> (1) Use Ant-like properties in the web.xml files (of the form 
> ${name}),
>     and use the <replaceproperties> Filter. Your web.xml 
> files thus act
>     as templates, and your <copy> (+filter) the actual files to use at
>     runtime.
> 

I couldn't find <replaceproperties> - do you have a link and is it
available in Ant 1.5.1?  I'm currently using a <filterset>
(http://ant.apache.org/manual/CoreTypes/filterset.html) with a bunch of
@name@ in my web.xml.  Your way sounds easier and cleaner.

Thanks,

Matt


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