# Passing arguments to a task

**URL:** <https://discuss.gradle.org/t/passing-arguments-to-a-task/8427>\
**Category:** Help/Discuss\
**Created:** [April 1, 2015, 6:14pm UTC](https://discuss.gradle.org/t/passing-arguments-to-a-task/8427 "2015-04-01T18:14:36Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![Dhamma\_Bob](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@Dhamma\_Bob](https://discuss.gradle.org/u/Dhamma_Bob)\
**Post date:** [April 2, 2015, 5:54pm UTC](https://discuss.gradle.org/t/passing-arguments-to-a-task/8427/21 "2015-04-02T17:54:07Z")

</div>

Ok, I figured out the problem. Apparently, it was this line that caused the mysterious task already exists problem.

```
from 'build.gradle' { into 'foobar' } 

```

Slightly revised code from yours causing the issue

```
apply plugin: 'java'
apply plugin: 'maven-publish'

group = 'org.gradle.foo'
version = '1.0.0-SNAPSHOT'

publishing {
    publications {
        module1(MavenPublication) {
            artifact myTask("foo")
        }
        module2(MavenPublication) {
            artifact myTask("bar")
        }
    }
}

def myTask(artifactName) {
    return tasks.create("my${artifactName}Task", Zip) {
        from 'build.gradle' { into 'foobar' } 
        baseName = artifactName
    }
}

```

If I change it to `from 'build.gradle' into 'foobar'`, the problem went away. Thanks for all your help!

---

<div class="post-metadata">

**Author:** ![vic-cw](https://avatars.discourse-cdn.com/v4/letter/v/c89c15/32.png) [@vic-cw](https://discuss.gradle.org/u/vic-cw)\
**Post date:** [January 21, 2018, 6:50pm UTC](https://discuss.gradle.org/t/passing-arguments-to-a-task/8427/22 "2018-01-21T18:50:14Z")

</div>

Link to equivalent stackoverflow question, for better quality : [https://stackoverflow.com/questions/20410854/how-to-pass-parameters-or-arguments-into-a-gradle-task/48370451#48370451](https://stackoverflow.com/questions/20410854/how-to-pass-parameters-or-arguments-into-a-gradle-task/48370451#48370451)

[Previous page](https://discuss.gradle.org/t/passing-arguments-to-a-task/8427.md?page=1)
