# Gradle parallel with inter-project artifact dependencies

**URL:** https://discuss.gradle.org/t/gradle-parallel-with-inter-project-artifact-dependencies/28214
**Category:** Help/Discuss
**Created:** [August 17, 2018, 9:37am UTC](https://discuss.gradle.org/t/gradle-parallel-with-inter-project-artifact-dependencies/28214 "2018-08-17T09:37:23Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ddimitrov](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ddimitrov/32/141_2.png) [@ddimitrov](https://discuss.gradle.org/u/ddimitrov)
#### Post date: [August 17, 2018, 9:37am UTC](https://discuss.gradle.org/t/gradle-parallel-with-inter-project-artifact-dependencies/28214/1 "2018-08-17T09:37:24Z")

</div>

I am having a few projects, where one project repackages the distribution of another.

I’ve structured this in a custom plugin as follows:

```
    def distributions = project.extensions.findByType(DistributionContainer)
    def embed = project.configurations.create("embed")
    
    def configDistribution = distributions.create("config") { Distribution d ->
        d.contents.from {
            embed.resolvedConfiguration.files.collect {
                it.name.endsWith('.tar') ? project.tarTree(it) : project.zipTree(it)
            }
        }
    }

    Task configDistTar = project.tasks.getByName(configDistribution.name + 'DistTar')
    project.artifacts.add('default', configDistTar)

```

This gets applied to every project, so any project can aggregate the distribution content of another by referencing it in the `embed` configuration.

It all works, but if I build `org.gradle.parallel=true`, the dependency between projects is not respected.

I would have expected that the distribution copy spec would try to resolve the configuration, which references an artifact, built by a task in different project.

Instead, when I do `gradle clean ass` I get spurious errors such as:

Could not read ‘…\build\distributions…tar’ as it does not exist.

---

<div class="post-metadata">

### Author: ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)
#### Post date: [August 17, 2018, 8:01pm UTC](https://discuss.gradle.org/t/gradle-parallel-with-inter-project-artifact-dependencies/28214/2 "2018-08-17T20:01:36Z")

</div>

You are using contents.from with a closure that is completely opaque to Gradle. So it doesn’t know that you are resolving a Configuration in there which would have needed the task dependencies to be run first. You’ll need to manually add the `embed` configuration as a dependency to the distribution tasks.

---

<div class="post-metadata">

### Author: ![ddimitrov](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ddimitrov/32/141_2.png) [@ddimitrov](https://discuss.gradle.org/u/ddimitrov)
#### Post date: [August 18, 2018, 12:01am UTC](https://discuss.gradle.org/t/gradle-parallel-with-inter-project-artifact-dependencies/28214/3 "2018-08-18T00:01:59Z")

</div>

Indeed… do you see any other way to achieve the same result without having to add explicit dependencies?

Also is there an api to get the dist tasks without relying on naming conventions?

---

<div class="post-metadata">

### Author: ![st\_oehme](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/st_oehme/32/5249_2.png) [@st\_oehme](https://discuss.gradle.org/u/st_oehme)
#### Post date: [August 18, 2018, 1:03am UTC](https://discuss.gradle.org/t/gradle-parallel-with-inter-project-artifact-dependencies/28214/4 "2018-08-18T01:03:22Z")

</div>

There’s no good alternative I’m afraid. We could probably add a method like `transformFiles` that people could use instead of Groovy’s `collect {}`.
