包括生成的android库的pom中的依赖项

时间:2016-05-26 12:17:18

标签: android maven android-gradle android-library artifactory

我试图将Android库发布到本地JFrog Artifactory。目前我有这个:

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
        }
    }
}

为了简洁起见,我跳过了一些像android和依赖项部分的部分。 build.gradle有多个编译依赖项。

gradle artifactoryPublish

将工件发布到Artifactory但生成的pom没有依赖关系。我找到了这个答案:https://stackoverflow.com/a/30523571/2829308

从这个答案中,pom.withXml起作用(尽管我无法弄清楚如何排除依赖关系)。但这似乎很苛刻。我觉得应该有更好的方法。我尝试使用uploadArchives方式,如下所示

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

它表示任务成功,但神器未在Artifactory中发布。我错过了一些明显的东西吗我该如何解决?

1 个答案:

答案 0 :(得分:0)

Pom文件不应包含传递依赖,只能包含直接依赖。 Maven解析pom文件以找到直接依赖关系,下载它们并以递归方式从那里继续。

您应该在pom文件中看到的唯一依赖项是在gradle脚本的dependences块中声明的依赖项。

相关问题