将具有多个模块的 Android 库发布到 jFrog artifactory 时出现问题
Issue in publishing Android library with multiple modules to jFrog artifactory
我的 Android 项目中有 2 个库模块。
mainlibrary
-sublibrary
子库模块正在主库中使用。在 build.gradle(模块:mainlibrary) 中,我导入了整个子库模块 -
implementation project(':sublibrary')
这就是我使用 jFrog artifactory 将 mainlibrary 作为库发布的方式,代码存在于 build.gradle(模块:mainlibrary) -
publishing {
publications {
aar(MavenPublication) {
groupId 'in.mikel.reusablelibs'
version '1.0.4'
artifactId project.getName()
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
}
}
}
artifactory {
contextUrl = 'https://mikel.jfrog.io/artifactory/'
publish {
repository {
// The Artifactory repository key to publish to
repoKey = 'mikelcl-gradle-release-local'
username = "***"
password = "***"
}
defaults {
// Tell the Artifactory Plugin which artifacts should be published to Artifactory.
publications('aar')
publishArtifacts = true
// Properties to be attached to the published artifacts.
properties = ['qa.level': 'basic', 'dev.team': 'core']
// Publish generated POM files to Artifactory (true by default)
publishPom = true
}
}
}
我还希望在发布到 jFrog artifactory 时打包 子库。
我需要在build.gradle(模块:子图书馆)中写单独的信息吗?如何处理?
您不必编写单独的 build.gradle 文件。您可以在根 build.gradle 中配置 sublibrary
。
例如:
project('sublibrary') {
publishing {
publications {
aar(MavenPublication) {
groupId 'in.mikel.reusablelibs'
version '1.0.4'
artifactId project.getName()
// Tell maven to prepare the generated "*.aar" file for publishing
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
}
}
}
artifactoryPublish {
publications(publishing.publications.aar)
}
}
确保在 sublibrary
项目中应用了 Artifactory 和 maven-publish 插件:
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
阅读更多:
我的 Android 项目中有 2 个库模块。
mainlibrary
-sublibrary
子库模块正在主库中使用。在 build.gradle(模块:mainlibrary) 中,我导入了整个子库模块 -
implementation project(':sublibrary')
这就是我使用 jFrog artifactory 将 mainlibrary 作为库发布的方式,代码存在于 build.gradle(模块:mainlibrary) -
publishing {
publications {
aar(MavenPublication) {
groupId 'in.mikel.reusablelibs'
version '1.0.4'
artifactId project.getName()
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
}
}
}
artifactory {
contextUrl = 'https://mikel.jfrog.io/artifactory/'
publish {
repository {
// The Artifactory repository key to publish to
repoKey = 'mikelcl-gradle-release-local'
username = "***"
password = "***"
}
defaults {
// Tell the Artifactory Plugin which artifacts should be published to Artifactory.
publications('aar')
publishArtifacts = true
// Properties to be attached to the published artifacts.
properties = ['qa.level': 'basic', 'dev.team': 'core']
// Publish generated POM files to Artifactory (true by default)
publishPom = true
}
}
}
我还希望在发布到 jFrog artifactory 时打包 子库。
我需要在build.gradle(模块:子图书馆)中写单独的信息吗?如何处理?
您不必编写单独的 build.gradle 文件。您可以在根 build.gradle 中配置 sublibrary
。
例如:
project('sublibrary') {
publishing {
publications {
aar(MavenPublication) {
groupId 'in.mikel.reusablelibs'
version '1.0.4'
artifactId project.getName()
// Tell maven to prepare the generated "*.aar" file for publishing
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
}
}
}
artifactoryPublish {
publications(publishing.publications.aar)
}
}
确保在 sublibrary
项目中应用了 Artifactory 和 maven-publish 插件:
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
阅读更多: