I am using Gradle to build an Android library project and deploy it to maven repository as an aar.
The library has some dependencies, which should be included in the POM
With apply plugin: 'maven'
no POM file is present, just the artifact
With apply plugin: 'maven-publish'
a POM file is generated, but it does not include any dependencies
Any ideas? Is this just not supported?
Gradle 2.2 and Android Gradle Plugin 1.1.0
First approach:
configurations {
archives {
extendsFrom configurations.default
}
}
afterEvaluate { project ->
uploadArchives {
configuration = configurations.archives
repositories {
mavenDeployer {
repository(url: "http://nexus-url") {
authentication(userName: nexusUsername, password: nexusPassword)
pom.groupId = 'com.example'
pom.version = '123-SNAPSHOT'
pom.artifactId = 'foo'
pom.packaging = 'aar'
pom.project {
artifactId = 'bar'
packaging 'aar'
description 'baz'
}
}
}
}
Also tried it without wrapping it in afterEvaluate
Second approach:
publishing {
publications {
sdk(MavenPublication) {
groupId 'com.example'
artifactId 'foo'
version = "0.123-SNAPSHOT"
artifact("$buildDir/outputs/aar/app-sdk-debug.aar")
}
}
repositories {
maven {
url "http://nexus-url"
credentials {
username 'foo'
password 'bar'
}
}
}
}
Update
The root cause of the problem is that this project uses flavors. Without flavors the pom is generated properly when using apply plugin: 'maven'
This is the solution that worked for me in the end:
try mavenDeployer: http://gradle.org/docs/current/userguide/maven_plugin.html
here you could set the pom details. You'll get a new goal called
uploadArchives
. When executed, it deploys to a given repo.