Due to implementation of a internal workaround in our dependency resolution, we need to modify the published pom file (being published with the maven-publish plugin) to adjust a dependency version. I can accomplish this in the published pom file using MavenPom.withXML():
mvnPublication.pom.withXml { XmlProvider xml ->
def hasDependencies = !asNode().dependencies.isEmpty()
if (hasDependencies) {
asNode().dependencies.first().each {
def groupId = it.get("groupId").first().value().first()
def version = it.get("version").first().value().first()
if (groupId == 'testGroup' && version == 'changeVersion') {
it.get("version").first().value = newVersion
}
}
}
}
While this appropriately changes the published pom file, the Gradle module metadata (module.json) still retains the original version. This causes an inconsistency in the published Maven pom file and Gradle module metadata.
What is the proper way to make such a change that is reflected in both the published Maven pom file and Gradle module.json file?