# Could not determine dependencies of task, while dynamically creating tasks

**URL:** <https://discuss.gradle.org/t/could-not-determine-dependencies-of-task-while-dynamically-creating-tasks/5442>\
**Category:** Old Forum Archive\
**Created:** [October 15, 2012, 1:29pm UTC](https://discuss.gradle.org/t/could-not-determine-dependencies-of-task-while-dynamically-creating-tasks/5442 "2012-10-15T13:29:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neil1](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@Neil1](https://discuss.gradle.org/u/Neil1)\
**Post date:** [October 15, 2012, 1:29pm UTC](https://discuss.gradle.org/t/could-not-determine-dependencies-of-task-while-dynamically-creating-tasks/5442/1 "2012-10-15T13:29:00Z")

</div>

Hi, I’m trying to dynamically create some tasks which package up various different artifacts. I’m also adding each of those tasks to the ‘compile’ artifact configuration. However I get the error message “Could not determine the dependencies of task ‘:uploadArtifacts’.”

If I remove the dynamic generation of tasks and type out the definition of the tasks long-hand then it works fine. Although I’d prefer not to do this because I may have many more different zips than just Debug and Release.

I was wondering if anyone could please help me with this.

The code:

```gradle
configurations {
    compile
}
["Debug", "Release"].each { conf ->
    task("package" + conf, type: Zip) {
        classifier = conf
        includes = ["src/*.h", "lib/$conf/*.lib"]
        baseName = 'external-lib'
        includeEmptyDirs = false
        from "."
    }
    configurations.compile.artifacts.add "package" + conf
}
task uploadArtifacts(type: Upload) {
    group = "Packaging"
    description = "Uploads all packages to the repository."
    uploadDescriptor = true
    descriptorDestination = new File("ivy.xml")
    configuration = configurations.compile
}

```

The command line: gradle tasks

The error: Execution failed for task ‘:tasks’. \> Could not determine the dependencies of task ‘:uploadArtifacts’.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [October 15, 2012, 1:46pm UTC](https://discuss.gradle.org/t/could-not-determine-dependencies-of-task-while-dynamically-creating-tasks/5442/2 "2012-10-15T13:46:00Z")

</div>

I’d be surprised if ‘configurations.compile.artifacts.add(someString)’ worked. Usually you’d do something like ‘artifacts { compile tasks[“package$conf”] }’. Instead of looking up the task with ‘tasks[“package$conf”]’, you could also store it in a variable upon creation (the ‘task’ method returns a ‘Task’ object).

---

<div class="post-metadata">

**Author:** ![Neil1](https://avatars.discourse-cdn.com/v4/letter/n/278dde/32.png) [@Neil1](https://discuss.gradle.org/u/Neil1)\
**Post date:** [October 15, 2012, 4:22pm UTC](https://discuss.gradle.org/t/could-not-determine-dependencies-of-task-while-dynamically-creating-tasks/5442/3 "2012-10-15T16:22:00Z")

</div>

Thanks Peter. You were right. I have corrected a subset of the above code to:

```gradle
["Debug", "Release"].each { conf ->
    artifacts {
        compile task("package" + conf, type: Zip) {
            classifier = conf
            includes = ["src/*.h", "lib/$conf/*.lib"]
            baseName = 'external-lib'
            includeEmptyDirs = false
            from "."
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [October 15, 2012, 4:38pm UTC](https://discuss.gradle.org/t/could-not-determine-dependencies-of-task-while-dynamically-creating-tasks/5442/4 "2012-10-15T16:38:00Z")

</div>

Creating the task inside the ‘artifacts’ block is very unusual. I guess it will work, but I don’t recommend it.
