On 30/03/2011, at 1:36 AM, Steve Ebersole wrote:

> I am having a tough time getting filtering to work.  I am trying to create a 
> zip file:
> task buildTutorialZip(type: Zip) {
>     destinationDir = project.buildDir
>     archiveName = 'hibernate-tutorials.zip'
>     from 'src/main/docbook/quickstart/tutorials'
>     filter(
>             org.apache.tools.ant.filters.ReplaceTokens,
>             tokens: ["{{version}}": project.version]
>     )
> }
> So I am trying to replace occurences of {{version}} with the project version. 
>  The filtering never happens.  What am I doing wrong?

The ReplaceTokens filter defaults to using @ as the token delimiter, so it will 
be looking for instances of @{{version}}@ to replace. I think you also need to 
specify begintoken: '{{' and endtoken: '}}' for this to work as you expect.


> On Friday, February 04, 2011, at 08:10 pm, Rene Groeschke wrote:
> > Hi Neil,
> > you needn't define a new task. you just have to augment the
> > processResources task. try this:
> > 
> > 
> > processResources {
> >   filter ReplaceTokens, tokens: [
> >           timestamp: new Date().dateTimeString,
> >           url: "http://localhost:8080/myapp "
> >   ]
> > }
> > 
> > regards,
> > René
> > 
> > Am 04.02.11 23:36, schrieb Neil Chaudhuri:
> > > I am an experienced Java developer and Maven user, and I am evaluating
> > > Gradle for a possible transition. So far I have my multi-module project
> > > building nicely and quite cleanly, and I have figured out how to get my
> > > configuration files to be filtered via the ReplaceTokens filter as
> > > follows:
> > > 
> > > task filter(type: Copy) {
> > > 
> > >   from 'src/main/resources'
> > >   into 'build/classes/main'
> > >   filter ReplaceTokens, tokens: [
> > >   
> > >           timestamp: new Date().dateTimeString,
> > >           url: "http://localhost:8080/myapp ",
> > > 
> > > .
> > > .
> > > .
> > > 
> > >   ]
> > > 
> > > }
> > > 
> > > Things work just fine when I call filter directly, but calling build
> > > doesn't call filter. As a result, the project is built with the files
> > > unfiltered. Can you provide some insight on the configuration I need to
> > > add to make sure my filter task is called as part of the build task?
> > > 
> > > Thanks.
> ---
> Steve Ebersole <[email protected]>
> http://hibernate.org


--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com

Reply via email to