Я пытаюсь опубликовать sh зависимостей моего Android проекта библиотеки в хранилище maven. Поэтому я добавляю приведенный ниже код в файл Gradle сборки.
publishing {
publications {
maven(MavenPublication) {
artifact bundleRelease
pom.withXml {
//Creating additional node for dependencies
def dependenciesNode = asNode().appendNode('dependencies')
//Defining configuration names from which dependencies will be taken (debugCompile or releaseCompile and compile)
def configurationNames = ["releaseCompile", 'compile', 'api', "implementation"]
configurationNames.each { configurationName ->
if (!configurations.names.contains(configurationName)) {
return
}
configurations[configurationName].allDependencies.each {
if (it.group != null && it.name != null) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
//If there are any exclusions in dependency
if (it.excludeRules.size() > 0) {
def exclusionsNode = dependencyNode.appendNode('exclusions')
it.excludeRules.each { rule ->
def exclusionNode = exclusionsNode.appendNode('exclusion')
exclusionNode.appendNode('groupId', rule.group)
exclusionNode.appendNode('artifactId', rule.module)
}
}
}
}
}
}
}
}
}
Я обнаружил, что мой pom-файл имеет двойные зависимости, содержание которых одинаково. Как показано ниже:
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
</dependency>
</dependencies>
Мои зависимости gradle с api
:
dependencies {
api "com.google.code.gson:gson:${gson_version}"
}
Я добавляю некоторые публикации в журналы. И я обнаружил, что конфигурации api
и implementation
имеют зависимость от библиотеки gson.
Я так растерялся. Кто-нибудь хотел бы объяснить, почему это произошло?