# Published Gradle Metadata modifications

**URL:** <https://discuss.gradle.org/t/published-gradle-metadata-modifications/42125>\
**Category:** Help/Discuss\
**Created:** [February 2, 2022, 8:52pm UTC](https://discuss.gradle.org/t/published-gradle-metadata-modifications/42125 "2022-02-02T20:52:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mondrejko](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@mondrejko](https://discuss.gradle.org/u/mondrejko)\
**Post date:** [February 2, 2022, 8:52pm UTC](https://discuss.gradle.org/t/published-gradle-metadata-modifications/42125/1 "2022-02-02T20:52:47Z")

</div>

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():

```gradle
        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?

---

<div class="post-metadata">

**Author:** ![kalayda](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kalayda](https://discuss.gradle.org/u/kalayda)\
**Post date:** [February 14, 2024, 9:31am UTC](https://discuss.gradle.org/t/published-gradle-metadata-modifications/42125/2 "2024-02-14T09:31:31Z")

</div>

Hi! Have you find the solution?

---

<div class="post-metadata">

**Author:** ![mattkhan](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mattkhan/32/91_2.png) [@mattkhan](https://discuss.gradle.org/u/mattkhan)\
**Post date:** [December 22, 2025, 3:40pm UTC](https://discuss.gradle.org/t/published-gradle-metadata-modifications/42125/3 "2025-12-22T15:40:46Z")

</div>

buried in the docs is [MavenPublication - Gradle DSL Version 9.2.1](https://docs.gradle.org/current/dsl/org.gradle.api.publish.maven.MavenPublication.html#org.gradle.api.publish.maven.MavenPublication:versionMapping(org.gradle.api.Action))

which refers to this api

```gradle
publishing {
  publications {
    maven(MavenPublication) {
      from components.java
      versionMapping {
        usage('java-runtime'){
          fromResolutionResult()
        }
      }
    }
  }
}

```

you could use the above or replace with custom logic as you like

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [December 23, 2025, 1:32am UTC](https://discuss.gradle.org/t/published-gradle-metadata-modifications/42125/4 "2025-12-23T01:32:07Z")

</div>

Generally, the recommendation is always to never manual fiddle with the pom or manual files, but instead fix the model / component, so that the intended result comes out, then it is also consistent among all.
