title: Gradle task is broken - cannot execute
body: <pre><code>import org.apache.tools.ant.filters.ReplaceTokens
  task genScript(type:Copy){
      copy{
          from "../../scripts/script.txt"
          into projectDir
          filter ReplaceTokens, tokens: [baseName: jar.baseName, version: jar.version, prefix: 'x']
      }
  }
  
  jar.doLast{
      tasks.genScript.execute()
  }
  </code></pre>
  
  <p><code>genScript</code> executes fine if I just click on it and run. But when I do <code>..\gradlew clean jar</code>, it gives me the following error:</p>
  
  <blockquote>
    <p>Could not find method execute() for arguments [] on task ':myModule:genScript' of type org.gradle.api.tasks.Copy.</p>
  </blockquote>
  
  <p>How to fix it?</p>
  
  <p>I am using Gradle 6.0.1.</p>