简体   繁体   English

使用 jFrog artifactory 发布了一个库,使用库时未加载外部依赖项

[英]Published a library with jFrog artifactory, external dependencies not loading when using library

I'm using jFrog artifactory to publish an Android Library.我正在使用 jFrog artifactory 发布一个 Android 库。 The library is getting published fine.图书馆出版得很好。 But when I try to use it, the gradle dependencies of the library are not loading up.但是当我尝试使用它时,库的 gradle 依赖项没有加载。

My pom.xml already has those dependencies.我的 pom.xml 已经有了这些依赖项。

My library has two modules -我的图书馆有两个模块 -

-app
-secondarymod

And this is my code in main project level build.gradle -这是我在主项目级别 build.gradle 中的代码 -

artifactoryPublish.skip = true

project('app') {
    artifactoryPublish.dependsOn('build')
    publishing {
        publications {
            aar(MavenPublication) {
                groupId = "in.mikkel.mainapp"
                artifactId = project.getName()
                version = "1.0.24"

                artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")

                pom.withXml {
                    def dependencies = asNode().appendNode("dependencies")
                    configurations.implementation.allDependencies.each {
                        def dependency = dependencies.appendNode("dependency")
                        print(it.group)
                        dependency.appendNode("groupId", it.group)
                        dependency.appendNode("artifactId", it.name)
                        dependency.appendNode("version", it.version)
                    }
                }

            }
        }
    }

    artifactoryPublish {
        publications(publishing.publications.aar)
    }
}

project('secondarymod') {
    artifactoryPublish.dependsOn('build')
    publishing {
        publications {
            aar(MavenPublication) {
                groupId = "in.mikkel.mainapp"
                artifactId = project.getName()
                version = "1.0.24"
                // Tell maven to prepare the generated "*.aar" file for publishing
                artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")

                pom.withXml {
                    def dependencies = asNode().appendNode("dependencies")
                    configurations.implementation.allDependencies.each {
                        def dependency = dependencies.appendNode("dependency")
                        print(it.group)
                        dependency.appendNode("groupId", it.group)
                        dependency.appendNode("artifactId", it.name)
                        dependency.appendNode("version", it.version)
                    }
                }

            }
        }
    }

    artifactoryPublish {
        publications(publishing.publications.aar)
    }
}

artifactory {
    contextUrl = 'https://mikkel.jfrog.io/artifactory'
    publish {
        repository {
            repoKey = 'mikkelcl-gradle-release-local'
            username = "***"
            password = "***"
        }
        defaults {
            publications('aar')
            publishArtifacts = true
            publishPom = true
        }
    }
}

Can anyone tell me what's wrong?谁能告诉我出了什么问题?

Generally speaking, in the package managers world, dependencies are never published.一般来说,在包管理器的世界里,从不发布依赖。 Only Artifacts does.只有 Artifacts 可以。 The dependencies should be downloaded in the CI in the same way you download them in your local machine.依赖项应以与在本地计算机中下载它们相同的方式在 CI 中下载。

If the dependencies are your private code, you should build and publish them separately.如果依赖项是您的私有代码,您应该单独构建和发布它们。

Otherwise, you should configure the dependencies repository on your build.gradle file.否则,您应该在build.gradle文件上配置依赖项存储库。 In that case, please make sure that the repository is configured in the repositories clause.在这种情况下,请确保在repositories子句中配置了repositories

Read more about Declaring repositories in Gradle here .此处阅读有关在 Gradle 中声明存储库的更多信息。

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

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