# Copy ReplaceTokens filter not working

**URL:** <https://discuss.gradle.org/t/copy-replacetokens-filter-not-working/5446>\
**Category:** Old Forum Archive\
**Created:** [October 18, 2012, 8:04pm UTC](https://discuss.gradle.org/t/copy-replacetokens-filter-not-working/5446 "2012-10-18T20:04:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![erichschroeter](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/erichschroeter/32/469_2.png) [@erichschroeter](https://discuss.gradle.org/u/erichschroeter)\
**Post date:** [October 18, 2012, 8:04pm UTC](https://discuss.gradle.org/t/copy-replacetokens-filter-not-working/5446/1 "2012-10-18T20:04:00Z")

</div>

I am trying to update a properties file located located at ‘src/main/resources/path/to/package/build.properties’ every time I run the build task. What I have so far is:

task updateVersion(type: Copy) \<\< {

ext.versions = project.version.split("\.")

from ‘src/main/resources/path/to/my/properties’

into getDestDir()

filter(ReplaceTokens, tokens: [major: versions[0], minor: versions[1], revision: versions[2]])

}

build.dependsOn updateVersion

All that is in my properties file is:

build.major=@major@

build.minor=@minor@

build.revision=@revision@

Am I getting the destination directory wrong? I tried specifying the specific location for the ‘into’ field, but that didn’t work either. I want to be able to let Gradle decide where my source files’ destination should be.

---

<div class="post-metadata">

**Author:** ![Rene](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/rene/32/8082_2.png) [@Rene](https://discuss.gradle.org/u/Rene)\
**Post date:** [October 18, 2012, 8:17pm UTC](https://discuss.gradle.org/t/copy-replacetokens-filter-not-working/5446/2 "2012-10-18T20:17:00Z")

</div>

you have to get rid of the “\<\<” in your task definition. At the momen, you’re adding a task action instead of configuring it.

cheers, René

---

<div class="post-metadata">

**Author:** ![erichschroeter](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/erichschroeter/32/469_2.png) [@erichschroeter](https://discuss.gradle.org/u/erichschroeter)\
**Post date:** [October 19, 2012, 11:04am UTC](https://discuss.gradle.org/t/copy-replacetokens-filter-not-working/5446/3 "2012-10-19T11:04:00Z")

</div>

So, I was able to get it working, but not with ‘getDestDir()’. I can’t figure out how to let Gradle decide where to put it for me, or if it is even possible to specify that.

task updateVersion(type: Copy) {

ext.versions = project.version.split("\.")

from ‘src/main/resources/path/to/my/properties’

into ‘build/resources/main/path/to/my/properties’

filter(ReplaceTokens, tokens: [major: versions[0], minor: versions[1], revision: versions[2]])

}

build.dependsOn updateVersion

jar.dependsOn updateVersion

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [October 21, 2012, 5:43am UTC](https://discuss.gradle.org/t/copy-replacetokens-filter-not-working/5446/4 "2012-10-21T05:43:00Z")

</div>

I don’t understand the question, as you are already using ‘into’ to determine the destination. Maybe your ‘getDestDir()’ method is computing the wrong value. By the way, to do resource filtering you’d just have to configure the ‘processResources’ task, which is also of type ‘Copy’.
