title: Gradle java project replace single line in file during build
body: <p>I have a simple Gradle build script to compile and package (similar to the application plugin) my Java application. The only thing I do not accomplish is to replace the current version number in a simple .properties file.</p>
  
  <p>I have created a file 'src/main/resources/app-info.properties' with a single line 'application.version = @version@'. No I want to replace this version string whenever the file is copied to the build folder (think this happens during the build task).</p>
  
  <p>I already tried a simple solution with ants ReplaceTokens. This one replaced the version but also broke my .png files in the resources..</p>
  
  <p>So is there a simple solution to just replace tokens in one single file during the build task (or whatever task handles the copy to the build folder)?</p>
  
  <p>Thank you for any help!
  Ben</p>
  
  <p>====== Edit based on the comment from Opal =====</p>
  
  <p>Based on the hint I have added the following: </p>
  
  <pre><code>import org.apache.tools.ant.filters.ReplaceTokens
  // ... 
  build {
      from('src/main/resources') { 
          include '*.properties' 
          filter(ReplaceTokens, tokens: [version : project.version]) 
      } 
  } 
  </code></pre>
  
  <p>Which throws this error:</p>
  
  <blockquote>
    <p>Could not find method from() for arguments [src/main/resources, build_vbjud9ah7v3pj5e7c5bkm490b$_run_closure6_closure12@43ead1a8] on root project </p>
  </blockquote>
  
  <p>Seems like I am on the wrong task?</p>
  
  <p>====== Edit for completeness adding the solution based on Opals suggest =====</p>
  
  <p>Thanks man, the following is the working solution!</p>
  
  <pre><code>processResources {
      from('src/main/resources') {
          include '*.properties'
          filter(ReplaceTokens, tokens: [version : project.version])
      }
  }
  </code></pre>