Gradle not including dependencies in published pom.xml

前端 未结 7 1897
囚心锁ツ
囚心锁ツ 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 06:55

    Kotlin DSL version of the accepted answer:

        create("maven") {
            groupId = "com.example"
            artifactId = "sdk"
            version = Versions.sdkVersionName
            artifact("$buildDir/outputs/aar/Example-release.aar")
            pom.withXml {
                val dependenciesNode = asNode().appendNode("dependencies")
                val configurationNames = arrayOf("implementation", "api")
                configurationNames.forEach { configurationName ->
                    configurations[configurationName].allDependencies.forEach {
                        if (it.group != null) {
                            val dependencyNode = dependenciesNode.appendNode("dependency")
                            dependencyNode.appendNode("groupId", it.group)
                            dependencyNode.appendNode("artifactId", it.name)
                            dependencyNode.appendNode("version", it.version)
                        }
                    }
                }
            }
        }
    

提交回复
热议问题