【发布时间】:2020-12-17 06:03:22
【问题描述】:
您好,我正在尝试关注https://developer.android.com/studio/build/maven-publish-plugin 将库 (aar) 模块和应用程序 (apk) 模块发布到 maven 存储库(maven-publish 插件)。我正在使用 kotlin gradle kts 而不是 grovy
在 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'
}
}
}
我的 kotlin dls 发布 app 模块的代码
publications {
create<MavenPublication>("mastercardMavenApk") {
groupId = ProjectInfo.groupId
artifactId = ProjectInfo.artifactId
version = ProjectInfo.nexusVersion + if (useReleaseRepo) "" else "-SNAPSHOT"
from(components["mastercardDebug_apk"])
}
}
其中mastercardDebug 是我的Active Build Variant 之一
我总是有以下错误
SoftwareComponentInternal with name 'mastercardDebug_apk' not found
在android项目中使用maven-publishplugin的正确方法应该是什么(同时支持aar和apk模块)?
【问题讨论】:
标签: android kotlin gradle-kotlin-dsl maven-publish