Gradle not including dependencies in published pom.xml

前端 未结 7 1899
囚心锁ツ
囚心锁ツ 2020-12-02 06:26

I have a Gradle project I\'m using the maven-publisher plugin to install my android library to maven local and a maven repo.

That works, but the g

相关标签:
7条回答
  • 2020-12-02 07:18

    I was using the maven-publish plugin for publishing my aar dependency and actually I could not use the maven task in my case. So I used the mavenJava task provided by the maven-publish plugin and used that as follows.

    apply plugin 'maven-publish'
    
    publications {
        mavenAar(MavenPublication) {
            from components.android
        }
    
        mavenJava(MavenPublication) {
            pom.withXml {
                def dependenciesNode = asNode().appendNode('dependencies')
                // Iterate over the api dependencies (we don't want the test ones), adding a <dependency> node for each
                configurations.api.allDependencies.each {
                    def dependencyNode = dependenciesNode.appendNode('dependency')
                    dependencyNode.appendNode('groupId', it.group)
                    dependencyNode.appendNode('artifactId', it.name)
                    dependencyNode.appendNode('version', it.version)
                }
            }
        }
    }
    

    I hope that it helps someone who is looking for help on how to publish the aar along with pom file using the maven-publish plugin.

    0 讨论(0)
提交回复
热议问题