title: Modify an existing gradle task
body: <p>When <code>apply plugin: 'java'</code> in Gradle, it defines among other tasks <code>processResources</code>.
  I want to substitute the token/parameter in one of the resource file during <code>processResources</code>.
  I have the following copy task defined in my <code>build.gradle</code>:</p>
  
  <pre><code>import org.apache.tools.ant.filters.ReplaceTokens                                                                                                                                                                                         
  
  task initConfig(type: Copy) {                                                                                                                                                                                                             
      from("src/resources/assets/js") {                                                                                                                                                                                                     
          include 'config.js'                                                                                                                                                                                                               
          filter(ReplaceTokens, tokens: [host: "${System.env.HOST ?: 'localhost:58080'}" as String])                                                                                                                                        
      }                                                                                                                                                                                                                                     
      into "$sourceSets.main.output.resourcesDir/assets/js"                                                                                                                                                                                 
  }   
  </code></pre>
  
  <p>It works fine if I run <code>gradle -q run initConfig</code>.
  What I want is that this task to be run as part of <code>processResources</code> task, I've tried to put the same logic as following:</p>
  
  <pre><code>processResources &lt;&lt; {
      // same code goes here
  }
  </code></pre>
  
  <p>or </p>
  
  <pre><code>processResources {
      doLast {
          // same code goes here
      }
  }
  </code></pre>
  
  <p>None of them works. So, if run <code>gradle -q clean processResources</code> resources are copied, but the token is not replaced.</p>
  
  <p>I don't want to force explicitly run/add <code>initConfig</code> when running the build, so ideally <code>gradle -q build</code> should do everything necessary.</p>
  
  <p>I believe it is possible, as <code>build</code> task itself defines the way to run multiple tasks during its execution. Could not find yet how.</p>