on gradle0.8 filter(ReplaceTokens, propertiesfile: 'mysettings.properties')
gives:
Cause: Error - Invalid filter specification for
org.apache.tools.ant.filters.ReplaceTokens


Steve Appling wrote:
> 
> 
> 
> Hans Dockter wrote:
>> 
>> On Nov 4, 2009, at 3:04 PM, Jason Porter wrote:
>> 
>>> Sent from my iPhone
>>>
>>> On Nov 4, 2009, at 4:43, Levi Hoogenberg <levihoogenb...@gmail.com 
>>> <mailto:levihoogenb...@gmail.com>> wrote:
>>>
>>>> Hi Jason,
>>>>
>>>> I don't know if it's the Gradle way, but in one of my projects' 
>>>> build.gradle I have the following:
>>>>
>>>> processResources {
>>>>     filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: 
>>>> [version: project.version])
>>>> }
>>>>
>>>> This replaces @version@ in a property file, so that it can be read 
>>>> from the code.
>> 
>> The processResources task is of type Copy.
>> 
>> See 
>> Javadoc:
>> http://gradle.org/0.8/docs/javadoc/index.html?org/gradle/api/tasks/Copy.html
>> 
>> What you could do in your case:
>> 
>> Properties props = new Props()
>> props.load(...)
>> 
>> copy {
>>    from 'path_to_file_to_be_filtered'
>>    into ...
>>    props.each { key, value ->
>>       filter(ReplaceTokens, tokens: props) // It depends on you set up 
>> if this is exactly what you want.
>>    }
>> }
>> 
>> - Hans
>> 
>> --
>> Hans Dockter
>> Gradle Project Manager
>> http://www.gradle.org
> I haven't tried this, but I think the ReplaceTokens filter can read from a 
> properties file all by itself so you can do:
> copy {
>      from 'path_to_file_to_be_filtered'
>      into ...
>      filter(ReplaceTokens, propertiesfile: 'mysettings.properties')
> }
> 
> 
>> 
>>>>
>>>> Regards,
>>>>   Levi
>>>>
>>>> On Wed, Nov 4, 2009 at 7:46 AM, Jason Porter < 
>>>> <http://lightguard.jp/>lightguard.jp <http://lightguard.jp/>@ 
>>>> <http://gmail.com/>gmail.com <http://gmail.com/>> wrote:
>>>>
>>>>     In a war I've got I'd like to filter a file that ultimately ends
>>>>     up in
>>>>     the WEB-INF directory (chances are I'll just put it here under
>>>>     webapp/WEB-INF anyway), but I want to replace some tokens in it
>>>>     (preferably with items that exist in a properties file).  I know
>>>> how
>>>>     I'd do this in ant, but what's the gradle way of doing it?
>>>>
>>>>     --
>>>>     Jason Porter
>>>>     Real Programmers think better when playing Adventure or Rogue.
>>>>
>>>>     PGP key id: 926CCFF5
>>>>     PGP fingerprint: 64C2 C078 13A9 5B23 7738 F7E5 1046 C39B 926C CFF5
>>>>     PGP key available at: <http://keyserver.net/>keyserver.net
>>>>     <http://keyserver.net/>, <http://pgp.mit.edu/>pgp.mit.edu
>>>>     <http://pgp.mit.edu/>
>>>>
>>>>    
>>>> ---------------------------------------------------------------------
>>>>     To unsubscribe from this list, please visit:
>>>>
>>>>        
>>>>    
>>>> <http://xircles.codehaus.org/manage_email>http://xircles.codehaus.org/manage_email
>>>>
>>>>
>>>>
>>>
>>> That would work fine, but I don't want to list the tokens and their 
>>> values in the build file. I'd rather have them pulled from a 
>>> properties file (so it can change from box / environment). Think stuff 
>>> like user names and passwords, external locations, etc.
>> 
> 
> -- 
> Steve Appling
> Automated Logic Research Team
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-to-do-a-copy-filter-the-gradle-way--tp26191753p26280426.html
Sent from the gradle-user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to