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
This is the solution that worked for me in the end:
publishing {
publications {
sdk(MavenPublication) {
artifactId libName
artifact "${project.buildDir}/outputs/aar/${libName}-${project.version}.aar"
//The publication doesn't know about our dependencies, so we have to manually add them to the pom
pom.withXml {
// for dependencies and exclusions
def dependenciesNode = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.withType(ModuleDependency) { ModuleDependency dp ->
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dp.group)
dependencyNode.appendNode('artifactId', dp.name)
dependencyNode.appendNode('version', dp.version)
// for exclusions
if (dp.excludeRules.size() > 0) {
def exclusions = dependencyNode.appendNode('exclusions')
dp.excludeRules.each { ExcludeRule ex ->
def exclusion = exclusions.appendNode('exclusion')
exclusion.appendNode('groupId', ex.group)
exclusion.appendNode('artifactId', ex.module)
}
}
}
}
}
}
repositories {
maven {
name 'myrepo'
url 'https://maven.foo.com'
credentials {
username mavenUsername
password mavenPassword
}
}
}
}
try mavenDeployer: http://gradle.org/docs/current/userguide/maven_plugin.html
uploadArchives {
repositories {
mavenDeployer {
repository(url: "file://localhost/tmp/myRepo/")
pom.version = '1.0Maven'
pom.artifactId = 'myMavenName'
}
}
}
here you could set the pom details. You'll get a new goal called uploadArchives
. When executed, it deploys to a given repo.