问题描述
有人可以告诉我如何使用 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 发布