[英]Issue in publishing Android library with multiple modules to jFrog artifactory
I have 2 library modules in my Android project.我的 Android 项目中有 2 个库模块。
mainlibrary
-sublibrary
The sublibrary module is being used in mainlibrary.子库模块正在主库中使用。 Inside build.gradle (Module: mainlibrary) , I have imported the entire sublibrary module -
在build.gradle (Module: mainlibrary) 中,我导入了整个子库模块 -
implementation project(':sublibrary')
This is how I ship mainlibrary as a library using jFrog artifactory, code present in build.gradle (Module: mainlibrary) -这就是我使用 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
}
}
}
I also want sublibrary to be packaged when publishing to jFrog artifactory.我也想子库发布到jFrog artifactory的时候要打包。
Do I need to write separate information in build.gradle (Module: sublibrary) ?我需要在 build.gradle (Module: sublibrary) 中编写单独的信息吗? How can that be handled ?
怎么处理?
You don't have to write a separate build.gradle file.您不必编写单独的 build.gradle 文件。 You can configure
sublibrary
in the root build.gradle.您可以在根 build.gradle 中配置
sublibrary
库。 For example:例如:
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)
}
}
Make sure Artifactory and maven-publish plugins are applied in the sublibrary
project:确保在子
sublibrary
项目中应用了 Artifactory 和 maven-publish 插件:
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
Read more:阅读更多:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.