4

I'm trying to publish an Android library to a local JFrog Artifactory. Currently I have this:

apply plugin: 'com.jfrog.artifactory'
apply plugin: 'maven-publish'
apply plugin: 'com.android.library'

publishing {
    publications {
        aar(MavenPublication) {
            groupId libraryGroupId
            version libraryVersion
            artifactId libraryArtifactId

            artifact("$buildDir/outputs/aar/app-beta-debug.aar")
        }
    }
}

artifactory {
    contextUrl = 'http://localhost:8081/artifactory'
    publish {
        repository {
            repoKey = 'libs-release-local'

            username = artifactory_username
            password = artifactory_password
        }
        defaults {
            publications('aar')
            publishArtifacts = true

            properties = ['qa.level': 'basic', 'q.os': 'android', 'dev.team': 'core']
            publishPom = true
        }
    }
}

I have skipped some parts like android and dependencies sections for brevity. The build.gradle has multiple compile dependencies.

gradle artifactoryPublish

published the artifact to Artifactory but the generated pom doesn't have the dependencies. I found this answer: https://stackoverflow.com/a/30523571/2829308

from this answer, pom.withXml worked (although I couldn't figure out how to exclude a dependency). But this seems hackish. I feel like there should be a better way available. I tried using the uploadArchives way as follows

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "http://localhost:8081/artifactory/libs-release-local")
            pom.version = libraryVersion
            pom.artifactId = libraryArtifactId
            pom.groupId = libraryGroupId
        }
    }
}

It says task successful but artifact doesn't get published in Artifactory. Am I missing something obvious? How do I fix this?

gitter
  • 1,706
  • 1
  • 20
  • 32

1 Answers1

0

Pom file shouldn't include transitive dependencies, only direct ones. Maven parses the pom files to find direct dependencies, download them and continue from there in a recursive manner.

The only dependencies that you should see in your pom file are the ones declared in the dependences block of your gradle script.

JBaruch
  • 22,610
  • 5
  • 62
  • 90
  • 2
    I think that's what he's saying. The library project has dependencies and they aren't included in his pom. I'm having the same issue unless I do that hack. – CaptRespect Sep 19 '16 at 20:12