dependencies {
...
api ("com.jakewharton:butterknife:${rootProject.ext.butterKnifeVersion}"){
exclude group: 'com.android.support', module: 'support-compat'
exclude group: 'com.android.support', module: 'support-annotations'
}
...
}
发布过程如下:
publishing {
publications {
bintrayMavenPublication(MavenPublication) {
groupId theGroupId
artifactId theArtifactId
version theVersion
artifact androidJavadocsJar
artifact androidSourcesJar
artifact bundleRelease
pom.withXml {
final dependenciesNode = asNode().appendNode('dependencies')
ext.addDependency = { Dependency dep, String scope ->
final dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('artifactId', dep.group == theGroupId ? dep.name.substring(9) : dep.name)
dependencyNode.appendNode('version', dep.version)
dependencyNode.appendNode('scope', scope)
if (!dep.transitive) {
final exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion')
exclusionNode.appendNode('groupId', '*')
exclusionNode.appendNode('artifactId', '*')
} else if (!dep.properties.excludeRules.empty) {
final exclusionNode = dependencyNode.appendNode('exclusions').appendNode('exclusion')
dep.properties.excludeRules.each { ExcludeRule rule ->
exclusionNode.appendNode('groupId', rule.group ?: '*')
exclusionNode.appendNode('artifactId', rule.module ?: '*')
}
}
}
configurations.api.getAllDependencies().each { dep -> addDependency(dep, "compile") }
configurations.implementation.getAllDependencies().each { dep -> addDependency(dep, "runtime") }
}
}
}
}
结果,pom文件有:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>library-example</artifactId>
<version>1.0.0</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>com.jakewharton</groupId>
<artifactId>butterknife</artifactId>
<version>8.8.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>com.android.support</groupId>
<artifactId>support-annotations</artifactId>
<groupId>com.android.support</groupId>
<artifactId>support-compat</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
就像你现在看到的
<exclusion>
<artifactId>
还有两个
<groupId>
. 如何修复并将其拆分为两个单独的标记
<
?
错误是:
-
出了什么问题:
无法将发布“bintrayMavenPublication”发布到存储库“mavenCustom”
发布“bintrayMavenPublication”无效:POM文件无效。检查对POM文件所做的任何修改。