title: How to pass parameters or arguments into a Gradle task?
body: <p>I have a Gradle build script into which I am trying to include <a href="http://eriwen.github.io/gradle-css-plugin/" rel="nofollow noreferrer">Eric Wendelin's CSS plugin</a>.</p>
  <p>It's easy enough to implement, and because I only want minification (rather than combining and gzipping), I've got the pertinent parts of the build script looking like this:</p>
  <pre><code>minifyCss {
      source = &quot;src/main/webapp/css/brandA/styles.css&quot;
      dest = &quot;${buildDir}/brandA/styles.css&quot;
      yuicompressor {
          lineBreakPos = -1
      }
  }
  
  war {
      baseName = 'ex-ren'
  }
  
  war.doFirst {
      tasks.myTask.minifyCss.execute()
  }
  </code></pre>
  <p>This is perfect - when I run the gradle war task, it calls the minifyCss task, takes the source css file, and creates a minified version in the buildDir</p>
  <p>However, I have a handful of css files which need minify-ing, but not combining into one file (hence I'm not using the combineCss task)</p>
  <p>What I'd like to be able to do is make the source and dest properties (assuming that's the correct terminology?) of the minifyCss task reference variables of some sort - either variables passed into the task in the signature, or global variables, or something ...</p>
  <p>Something like this I guess (which doesn't work):</p>
  <pre><code>minifyCss(sourceFile, destFile) {
      source = sourceFile
      dest = destFile
      yuicompressor {
          lineBreakPos = -1
      }
  }
  
  war {
      baseName = 'ex-ren'
  }
  
  war.doFirst {
      tasks.myTask.minifyCss.execute(&quot;src/main/webapp/css/brandA/styles.css&quot;, &quot;${buildDir}/brandA/styles.css&quot;)
      tasks.myTask.minifyCss.execute(&quot;src/main/webapp/css/brandB/styles.css&quot;, &quot;${buildDir}/brandB/styles.css&quot;)
      tasks.myTask.minifyCss.execute(&quot;src/main/webapp/css/brandC/styles.css&quot;, &quot;${buildDir}/brandC/styles.css&quot;)
  }
  </code></pre>
  <p>This doesn't work either:</p>
  <pre><code>def sourceFile = null
  def destFile = null
  
  minifyCss {
      source = sourceFile
      dest = destFile
      yuicompressor {
          lineBreakPos = -1
      }
  }
  
  war {
      baseName = 'ex-ren'
  }
  
  war.doFirst {
      sourceFile = &quot;src/main/webapp/css/brandA/styles.css&quot;
      destFile = &quot;${buildDir}/brandA/styles.css&quot;
      tasks.myTask.minifyCss.execute()
  }
  </code></pre>
  <p>For the life of me I cannot work out how to call a task and pass variables in :(</p>
  <p>Any help very much appreciated;</p>