繁体   English   中英

将具有多个模块的 Android 库发布到 jFrog artifactory 的问题

[英]Issue in publishing Android library with multiple modules to jFrog artifactory

我的 Android 项目中有 2 个库模块。

mainlibrary
  -sublibrary

子库模块正在主库中使用。 build.gradle (Module: 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 (Module: sublibrary) 中编写单独的信息吗? 怎么处理?

您不必编写单独的 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'

阅读更多:

  1. 例子
  2. 文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM