On Wed, Mar 24, 2010 at 9:52 PM, Jason Porter <[email protected]>wrote:
> On Wed, Mar 24, 2010 at 01:25, Hans Dockter <[email protected]> wrote: > >> Hi Jesse, >> >> On Wed, Mar 24, 2010 at 8:18 AM, Jesse Eichar < >> [email protected]> wrote: >> >>> Hi, >>> >>> I want to do the ant filter: >>> >>> ant.copy (todir: "$buildDir/webappSource") { >>> fileset(dir: "src/main/filtered-webapp") >>> filterset (begintoken: '@', endtoken: '@'){ >>> filtersfile(file: >>> "${project(':proxy:config').projectDir}/filters/global-resource.filter") >>> } >>> } >>> >>> I can see from the API how to do this if the filters are in memory. >>> Something like: >>> >>> task copyTask(type: Copy) { >>> from 'src/main/webapp' >>> into 'build/explodedWar' >>> >>> filter(ReplaceTokens, tokens:[copyright:'2009', version:'2.3.1']) >>> } >>> >>> Should I use ReplaceTokens and simply pass the Properties object to the >>> method? Or is there a cleaner way? >>> >> >> The above is the supposed way of doing it. >> > > This works fine, but there really should be a cleaner way in Gradle to do > this. It's a very common thing and maybe some syntactic sugar is in order > (at the very least something like tokenFile: <properties file>) so there's > no need to build the properties yourself. Of course then you get into the > problem of multiple properties files. > One improvement would be to have some properties factory: filter(ReplaceTokens, tokens: properties('propfile1', 'propfile2', [key1: 'value1'], someMap) I have created a Jira for this: http://jira.codehaus.org/browse/GRADLE-871 The other problem is that you always need to import the ReplaceTokens class. We either could either provide our own ReplaceTokens implementation or add the Ant ReplaceTokens class to the default imports. - Hans -- Hans Dockter Founder, Gradle http://www.gradle.org, http://twitter.com/gradleorg CEO, Gradle Inc. - Gradle Training, Support, Consulting http://www.gradle.biz
