What's a safe (i.e. cross-platform) way to replace tokens in processResources?

I’d like to filter all resources (binary files included) but I can’t because on some platforms it corrupts my gif files (as evidenced by a change in the md5 sum). So I’m doing this:

processResources {
 inputs.properties( version: version.toString() )
 // work-around for filter corrupting gif resources on the build server
 from(sourceSets.main.resources.srcDirs) {
  include '**/*.properties'
  filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: [VERSION: version.toString()])
  }
 from(sourceSets.main.resources.srcDirs) {
  exclude '**/*.properties'
 }
}

What’s a safe (i.e. cross-platform) way to replace tokens in processResources?

the filter() method is the way to go. It shouldn’t corrupt for bin files. Seems like a bug. On what platform do you have problems?

It’s not working for me in this environment:

------------------------------------------------------------ Gradle 1.0-milestone-3 ------------------------------------------------------------

Gradle build time: Monday, 25 April 2011 5:40:11 PM EST Groovy: 1.7.10 Ant: Apache Ant™ version 1.8.2 compiled on December 20 2010 Ivy: 2.2.0 JVM: 1.6.0_14 (Sun Microsystems Inc. 14.0-b16) OS: Linux 2.6.21.7-2.fc8xen i386

And works fine in this environment:

------------------------------------------------------------ Gradle 1.0-milestone-3 ------------------------------------------------------------

Gradle build time: Monday, 25 April 2011 5:40:11 PM EST Groovy: 1.7.10 Ant: Apache Ant™ version 1.8.2 compiled on December 20 2010 Ivy: 2.2.0 JVM: 1.6.0_26 (Apple Inc. 20.1-b02-384) OS: Mac OS X 10.6.8 x86_64

Thanks, Luke.

Unfortunately you are hitting GRADLE-1566.

I’m going to mark this question as answered, as you are doing the right thing but are hitting a bug in Gradle. To follow/comment on this problem please do so on the issue ticket.