# uploadArchives empty archives when setting dependsOn

**URL:** <https://discuss.gradle.org/t/uploadarchives-empty-archives-when-setting-dependson/10860>\
**Category:** Help/Discuss\
**Tags:** plugins\
**Created:** [July 29, 2015, 2:47pm UTC](https://discuss.gradle.org/t/uploadarchives-empty-archives-when-setting-dependson/10860 "2015-07-29T14:47:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicola](https://avatars.discourse-cdn.com/v4/letter/n/41988e/32.png) [@Nicola](https://discuss.gradle.org/u/Nicola)\
**Post date:** [July 29, 2015, 2:47pm UTC](https://discuss.gradle.org/t/uploadarchives-empty-archives-when-setting-dependson/10860/1 "2015-07-29T14:47:29Z")

</div>

Hello everyone!  
(I have posted the same question to [here](http://stackoverflow.com/questions/31614735/gradle-uploadarchives-artificats-namespace-when-depending-on-a-plugin), no answers yet…)  
I have a Android app building with Gradle. I am using the [gradle-release plugin](https://github.com/researchgate/gradle-release) to create automatic releases, and then the uploadArchives task from the maven plugin to upload the generated .apk to a Maven repo (Nexus).

I have to add the archives to upload dynamically at execution time, because my build is using custom Android flavors and I don’t know at configuration time which artifacts will be created.  
Everything works fine when I run uploadArchives normally:

```
def capitalizedVariantName = variant.name.capitalize()

variant.outputs.each { output ->
    def apkFile = output.outputFile

    tasks."assemble${capitalizedVariantName}" << {
        artifacts.archives [file: apkFile, classifier: variant.baseName]
    }
}

uploadArchives {
    repositories {
        mavenDeployer {
            pom.groupId = PROJECT_GROUP
            pom.artifactId = PROJECT_NAME
        }
    }
}

```

Then I run:

```
./gradlew assembleFlavorNameRelease uploadArchives

```

The .apk is correctly uploaded to Nexus.

I have the need to run the uploadArchives task BEFORE the release plugin automatically changes the version name of the project and commit.  
Basically:

- current version: 0.1.0-SNAPSHOT
- run release
- version becomes: 0.1.0
- build (build task)
- upload this build to Nexus (uploadArchives task)
- update the version to: 0.1.1-SNAPSHOT (updateVersion task)

To achieve this, what I have done is to have the updateVersion task of the gradle-release plugin depending on the uploadArchives

```
updateVersion.dependsOn uploadArchives

```

Well, when I do this, the artificats.archives. is empty, so no upload.

I suspect that, maybe, since I add the uploadArchives task as dependency of a task of the release plugin, then the “namespace” is different, so basically the uploadArchives task does not use the “same instance” of artifacts.archives, filled during the build.

Does anyone has a solution for that?
