# Pass parameters to task

**URL:** <https://discuss.gradle.org/t/pass-parameters-to-task/3440>\
**Category:** Old Forum Archive\
**Created:** [November 10, 2012, 5:58pm UTC](https://discuss.gradle.org/t/pass-parameters-to-task/3440 "2012-11-10T17:58:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![queshaw](https://avatars.discourse-cdn.com/v4/letter/q/d6d6ee/32.png) [@queshaw](https://discuss.gradle.org/u/queshaw)\
**Post date:** [November 10, 2012, 5:58pm UTC](https://discuss.gradle.org/t/pass-parameters-to-task/3440/1 "2012-11-10T17:58:00Z")

</div>

I want to effectively invoke a task multiple times with different values each time. How can I do this? Or what is a better way? Can a task be passed parameters? Or, configured and run multiple times, or something else? For example:

task abc \<\< {

println “$x $y” }

Have different values for x and y when the task is executed.

The real thing I’m trying to do at the moment is create a JavaExec task that can be reused with different inputs and outputs each time.

---

<div class="post-metadata">

**Author:** ![Szczepan\_Faber](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/szczepan_faber/32/213_2.png) [@Szczepan\_Faber](https://discuss.gradle.org/u/Szczepan_Faber)\
**Post date:** [November 12, 2012, 12:12pm UTC](https://discuss.gradle.org/t/pass-parameters-to-task/3440/2 "2012-11-12T12:12:00Z")

</div>

Gradle won’t let you run the same task multiple times within a single build.

The solution to your problem is to create a task instance for every set of inputs. Alternatively you can use task rules (see the user guide for more info).

Hope that helps!
