You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Timothy Shadel <sh...@mtc.byu.edu> on 2001/09/11 21:50:22 UTC

Filter task w/ properties file

I want to replace these lines in my build.xml :

		<filter token="VERSION_MAJOR" value="${version.major}" />
		<filter token="VERSION_MINOR" value="${version.minor}" />
		<filter token="BUILD_NUMBER" value="${version.buildnum}" />

with a file (filter.properties) like this:

VERSION_MAJOR=${version.major}
VERSION_MINOR=${version.minor}
BUILD_NUMBER=${version.buildnum}

and place this in my build.xml:

		<filter filtersfile="filter.properties" />

But the problem is that the Filter task (more specifically the FilterSet object to which it delegates file loading) doesn't replace the ${} property references with the project's values for those properties.  Instead it leaves the full string and ${} in when it filters the files during copy.  

If I can pull similar filters out of my build file I believe that would definitely make it MORE readable, but it's not worth it if I can't have access to the project's properties.  Is there a particular reason it's not done this way, and a workaround to accomplish the same thing?  Or has it just not made it in to the feature set yet?

Thanks,

Tim


Re: Filter task w/ properties file

Posted by Erik Hatcher <ja...@ehatchersolutions.com>.
You could use <propertyfile> to write your properties to a file, then read
them in using <filter> as a workaround.

    Erik


----- Original Message -----
From: "Timothy Shadel" <sh...@mtc.byu.edu>
To: <an...@jakarta.apache.org>
Sent: Tuesday, September 11, 2001 12:50 PM
Subject: Filter task w/ properties file


I want to replace these lines in my build.xml :

<filter token="VERSION_MAJOR" value="${version.major}" />
<filter token="VERSION_MINOR" value="${version.minor}" />
<filter token="BUILD_NUMBER" value="${version.buildnum}" />

with a file (filter.properties) like this:

VERSION_MAJOR=${version.major}
VERSION_MINOR=${version.minor}
BUILD_NUMBER=${version.buildnum}

and place this in my build.xml:

<filter filtersfile="filter.properties" />

But the problem is that the Filter task (more specifically the FilterSet
object to which it delegates file loading) doesn't replace the ${} property
references with the project's values for those properties.  Instead it
leaves the full string and ${} in when it filters the files during copy.

If I can pull similar filters out of my build file I believe that would
definitely make it MORE readable, but it's not worth it if I can't have
access to the project's properties.  Is there a particular reason it's not
done this way, and a workaround to accomplish the same thing?  Or has it
just not made it in to the feature set yet?

Thanks,

Tim