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>
。如何修复它并将其拆分为两个单独的标签<exclusion>
?
错误是:
失败:构建失败,并出现异常。
出了什么问题
任务':mvpr:publishBintrayMavenPublicationPublicationToMavenCustomRepository'的执行失败。
无法将发布'bintrayMavenPublication'发布到存储库'mavenCustom' 无效的发布'bintrayMavenPublication':POM文件无效。检查您对POM文件所做的任何修改。
尝试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。使用--scan运行以获取完整的见解。
- 获得更多帮助
答案 0 :(得分:1)
修正:
...
} else if (!dep.properties.excludeRules.empty) {
// Otherwise add specified exclude rules
final exclusionsNode = dependencyNode.appendNode('exclusions')
dep.properties.excludeRules.each { ExcludeRule rule ->
def exclusion = exclusionsNode.appendNode('exclusion')
exclusion.appendNode('groupId', rule.group ?: '*')
exclusion.appendNode('artifactId', rule.module ?: '*')
}
}
...