You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Christian Ashby <an...@cashby.me.uk> on 2004/08/17 20:51:30 UTC
Mapping properties before filtering
Hi,
I want to setup a FilterSet from a user configuration properties file.
The tokens within the properties file are all prefixed 'token.' or
'token.{server}.' and I need to map these to their actual token names
before passing them to the filterset.
As an example, user.properties contains:
token.APP_NAME=demo
token.weblogic.JSP_DOCROOT=/demo/demo
token.weblogic.STATIC_DOCROOT=/demo
token.iAS.JSP_DOCROOT=/NASApp/demo/demo
token.iAS.STATIC_DOCROOT=/NASApp/demo/demo
The server.type property is set at execution time to do this parsing.
I know that it can be done by using PropertyFile to write out a temporary
property file from a PropertySet with a Mapper, but this seems clunky and
akward to me.
Am I missing a cleaner solution, or is this about the only way to achieve
this aim?
Thanks,
Christian Ashby
Spiralinks, Inc.
http://www.spl.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Mapping properties before filtering
Posted by Christian Ashby <an...@cashby.me.uk>.
Just to slightly redefine the problem:
> I want to setup a FilterSet from a user configuration properties file.
>
<snip>
>
> Am I missing a cleaner solution, or is this about the only way to
> achieve this aim?
Basically the <FileSet> needs to be able to contain a <PropertySet>; I've
done the conversion as below:
<!-- Get tokens as a propertyset -->
<propertyset id="deploy.tokens">
<propertyref prefix="token." />
<mapper type="glob" from="token.*" to="*" />
</propertyset>
<!-- Get server-specific tokens as a propertyset -->
<propertyset id="server.deploy.tokens">
<propertyref prefix="${server.type}.token." />
<mapper type="glob" from="${server.type}.token.*" to="*" />
</propertyset>
<echoproperties>
<propertyset refid="deploy.tokens"/>
<propertyset refid="server.deploy.tokens"/>
</echoproperties>
And therefore have a propertyset of all tokens. At the moment I'm having
to write this to a properties file befora calling:
<copy toDir="${dest.dir}">
<fileset dir="${src.dir}">
<include name="**/*.html">
</fileset>
<filterset begintoken="%" endtoken="*">
<filtersfile file="${temp.dir}/user.tokens"/>
<filtersfile file="${temp.dir}/server.tokens"/>
</filterset>
</copy>
Rather than (which would be nicer!)
<copy toDir="${dest.dir}">
<fileset dir="${src.dir}">
<include name="**/*.html">
</fileset>
<filterset begintoken="%" endtoken="*">
<propertyset refid="deploy.tokens"/>
<propertyset refid="server.deploy.tokens"/>
</filterset>
</copy>
Is this worth implementing? I may well attempt to do so if people think it
worthwhile.
Thanks for your time,
Christian.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org