How can I upload multiple flavors/artifacts with different POM-files using mavenDeployer?

Hello,

i am using the Android Gradle Plugin (v. 1.0.0) to build and deploy an android library project to a Nexus Repository. My Library has multiple product flavors and i want all flavors to be deployed to a repository.

To make all variants an output artifact of the Gradle project I set “publishNonDefault true” in build.gradle (See: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Library-Publication)

To deploy my artifacts i use the uploadArchives Task of the maven plugin. The problem is, when i run the uploadArchives task, all artifacts are deployed as .aar files successfully, but without any POM-file.

When publishing only one flavor the artifact is uploaded correctly with a POM-file.

While trying to deploy all flavors I found out that in the buildDir/poms directory only one „default-pom.xml“ was generated. So I added filters for each flavor as stated here: http://www.gradle.org/docs/current/userguide/maven_plugin.html#sub:multiple_artifacts_per_project

Now I finally have a pom.xml for each flavor, for example: pom-flavor1Debug.xml or pom-flavor2Debug.xml But the problem is still there: None of these pom-Files are deployed to my repository.

Is it possible to deploy multiple flavors of a library as .aar with different POM-files at all? Am I missing something?

build.grade:

apply plugin: 'com.android.library'
  android {
      productFlavors {
        flavor1 {}
        flavor2 {}
    }
      publishNonDefault true
}
  apply plugin: 'maven'
  uploadArchives {
    repositories {
        mavenDeployer {
              repository(url: "url to repository"){
            }
              addFilter('flavor1Debug') {artifact, file ->
                artifact.attributes.classifier.equals("flavor1Debug")
            }
            addFilter('flavor2Debug') {artifact, file ->
                artifact.attributes.classifier.equals("flavor2Debug")
            }
              pom('flavor1Debug').artifactId = "flavor1-debug"
            pom('flavor2Debug').artifactId = "flavor2-debug"
        }
      }
}

I stumbled across the same issue. In my case, everything is uploaded: sources, javadoc, aar, and all signature-files (including the signature-file for the pom), but not the pom-file itself.

The libraries can get downloaded via gradle, if you know the exact syntax and data to provide for the library, however, without a pom, it will not be synced throughout the repositories nor will it possible to look them up. Actually, we can be lucky that the upload isn’t outright rejected…

Does anyone have an idea why this supposedly working feature is failing? Does it have something to do with the Android-Plugin? And if so, is it known how to “do it right”?

1 Like

I also ran into this issue. Did any of you find a solution yet?

Actually, no. I opened this report: http://forums.gradle.org/gradle/topics/multi-flavored-android-lib-doesnt-publish-pom-files-on-uploadarchives-task and my workaround is to run “uploadArchives” and then package everything into a zip-file and upload it manually as a bundle. Because actually, everything is generated just nicely, it’s just not uploaded.

1 Like