使用aar和源jar将Android库发布到Maven
问题描述:
有人可以给我提示如何使用maven-publish
gradle插件发布带有aar和源jar的com.android.library
项目/模块吗?我可以使用旧的maven插件执行此操作-但我想使用新的maven-publish
插件.
Can somebody give me a hint on how to use the maven-publish
gradle plugin to publish a com.android.library
project/module with aar and source jar? I am able to do this with the old maven plugin - but I would like to use the new maven-publish
plugin.
答
以下是使用新的maven-publish
插件的示例.
Here's a sample using the new maven-publish
plugin.
apply plugin: 'maven-publish'
task sourceJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier "sources"
}
publishing {
publications {
bar(MavenPublication) {
groupId 'com.foo'
artifactId 'bar'
version '0.1'
artifact(sourceJar)
artifact("$buildDir/outputs/aar/bar-release.aar")
}
}
repositories {
maven {
url "$buildDir/repo"
}
}
}
使用./gradlew clean build publish