简体   繁体   中英

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

I'm using jFrog artifactory to publish an Android Library. The library is getting published fine. But when I try to use it, the gradle dependencies of the library are not loading up.

My pom.xml already has those dependencies.

My library has two modules -

-app
-secondarymod

And this is my code in main project level 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. The dependencies should be downloaded in the CI in the same way you download them in your local machine.

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. In that case, please make sure that the repository is configured in the repositories clause.

Read more about Declaring repositories in Gradle here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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