Repositories.mavenDeployer don't add dependency type attribute to the result pom.xml

If you want to deploy library which has dependency on something different like .jar gradle generate invalid pom.xml for the library because it skip element in .

Example I have library project which has this dependency:

compile 'com.android.support:appcompat-v7:21.0.0'

During deploy gradle create this in the targer pom.xml

<dependencies>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>support-v4</artifactId>
      <version>21.0.3</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>

But aar is missing :frowning: So this pom.xml is invalid, because if is missing it should be jar, but jar type dependency doesn’t exist in the repo.

It is possible to fix it by this workaround

uploadArchives {
    repositories.mavenDeployer {
        pom.groupId = groupId
        pom.artifactId = artifactId
        pom.version = version
        // Add other pom properties here if you want (developer details / licenses)
        repository(url: "file://${localReleaseDest}")
        // workaround for: https://code.google.com/p/android/issues/detail?id=72807
        pom.whenConfigured { pom ->
            pom.dependencies.findAll { dependency ->
                if (dependency.artifactId == 'appcompat-v7') {
                    dependency.type = 'aar'
                }
            }
        }
    }
}

But I think that gradle should do itself.

Another topic with the same problem http://forums.gradle.org/gradle/topics/missing-in-deployed-pom-files-if-different-than-jar-artifact-is-used