[英]Use maven-publish to publish Android apk and aar with build variant (Android Gradle plugin 4.0)
I'm trying to followhttps://developer.android.com/studio/build/maven-publish-plugin to publish library (aar) module and application (apk) module to Maven repository ( maven-publish
plugin).我正在尝试按照https://developer.android.com/studio/build/maven-publish-plugin将库 (aar) 模块和应用程序 (apk) 模块发布到 Maven 存储库( maven-publish
插件)。 I'm using Kotlin Gradle kts instead of Grovy.我正在使用 Kotlin Gradle kts 而不是 Grovy。
Sample publish in Grovy (from link above)在 Grovy 中发布示例(来自上面的链接)
publishing {
publications {
paidRelease(MavenPublication) {
// The following applies a component to this publication
// which results in publishing an app bundle.
from components.paidRelease_aab
groupId = 'com.example.MyApp'
artifactId = 'paid-release-aab'
version = '1.0'
}
paidDebug(MavenPublication) {
// The following applies a component to this publication
// which results in publishing APKs in a ZIP file.
from components.paidDebug_apk
groupId = 'com.example.MyApp'
artifactId = 'paid-debug-apks'
version = '1.0'
}
}
}
My kotlin dls publishing code for app module我的 kotlin 应用程序模块的 dls 发布代码
publications {
create<MavenPublication>("mastercardMavenApk") {
groupId = ProjectInfo.groupId
artifactId = ProjectInfo.artifactId
version = ProjectInfo.nexusVersion + if (useReleaseRepo) "" else "-SNAPSHOT"
from(components["mastercardDebug_apk"])
}
}
where mastercardDebug
is one of my Active Build Variant
其中mastercardDebug
是我的Active Build Variant
之一
I always have below error:我总是有以下错误:
SoftwareComponentInternal with name 'mastercardDebug_apk' not found
What should be the correct way to use maven-publish
plugin for Android project (support both aar and apk module)?为 Android 项目使用maven-publish
插件的正确方法应该是什么(同时支持 aar 和 apk 模块)?
just use print(components.names)
before from(components["mastercardDebug_apk"])
to verify that the component exsists.只需在from(components["mastercardDebug_apk"])
之前使用print(components.names)
) 来验证组件是否存在。 maybe its just a typo也许这只是一个错字
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.