# Module replacement not reflected in publication metadata

**URL:** <https://discuss.gradle.org/t/module-replacement-not-reflected-in-publication-metadata/14113>\
**Category:** Bugs\
**Created:** [February 2, 2016, 6:53pm UTC](https://discuss.gradle.org/t/module-replacement-not-reflected-in-publication-metadata/14113 "2016-02-02T18:53:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danny\_Thomas1](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@Danny\_Thomas1](https://discuss.gradle.org/u/Danny_Thomas1)\
**Post date:** [February 2, 2016, 6:53pm UTC](https://discuss.gradle.org/t/module-replacement-not-reflected-in-publication-metadata/14113/1 "2016-02-02T18:53:18Z")

</div>

We want to define project and enterprise-wide module replacements to avoid conflicts due to changed coordinates, however they’re not reflected in the published metadata. Reduced case is:

```
apply plugin: 'java'
apply plugin: 'ivy-publish'

group = 'test'
version = '1.0'

repositories {
    jcenter()
}

dependencies {
    compile 'com.google.collections:google-collections:1.0'
    compile 'com.google.truth:truth:0.28' // Has a guava dependency
    modules {
        module("com.google.collections:google-collections") {
            replacedBy("com.google.guava:guava")
        }
    }
}

publishing {
    repositories {
        ivy {
            url 'build/testivyrepo'
            name 'testivy'
        }
    }
    publications {
        ivyPublish(IvyPublication) {
            from components.java
        }
    }
}

```

Results in:

```
<dependencies>
  <dependency org="com.google.collections" name="google-collections" rev="1.0" conf="runtime-&gt;default"/>
  <dependency org="com.google.truth" name="truth" rev="0.28" conf="runtime-&gt;default"/>
</dependencies>

```

For:

```
runtime - Runtime classpath for source set 'main'.
+--- com.google.collections:google-collections:1.0 -> com.google.guava:guava:18.0
\--- com.google.truth:truth:0.28
     +--- com.google.guava:guava:18.0
     \--- junit:junit:4.10
          \--- org.hamcrest:hamcrest-core:1.1
```

---

<div class="post-metadata">

**Author:** ![bmuschko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bmuschko/32/5458_2.png) [@bmuschko](https://discuss.gradle.org/u/bmuschko)\
**Post date:** [February 2, 2016, 11:21pm UTC](https://discuss.gradle.org/t/module-replacement-not-reflected-in-publication-metadata/14113/2 "2016-02-02T23:21:07Z")

</div>

I can reproduce the issue with Gradle 2.10. I believe this is missing feature/bug for the module replacement functionality. Looking at the [spec](https://github.com/gradle/gradle/blob/master/design-docs/conflict-resolution-spec.md#feature-conflict-resolution-replaces-a-module-or-modules-with-a-single-module) I couldn’t see a story that mentioned the integration with any of the publishing plugins. Briefly looking at the Gradle source code doesn’t reveal a test case that would verify the correct behavior.

I raised GRADLE-3390.

---

<div class="post-metadata">

**Author:** ![Danny\_Thomas1](https://avatars.discourse-cdn.com/v4/letter/d/e68b1a/32.png) [@Danny\_Thomas1](https://discuss.gradle.org/u/Danny_Thomas1)\
**Post date:** [February 2, 2016, 11:28pm UTC](https://discuss.gradle.org/t/module-replacement-not-reflected-in-publication-metadata/14113/3 "2016-02-02T23:28:14Z")

</div>

I guess that would mean this also applies to `resolutionStrategy` configurations too?

---

<div class="post-metadata">

**Author:** ![bmuschko](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/bmuschko/32/5458_2.png) [@bmuschko](https://discuss.gradle.org/u/bmuschko)\
**Post date:** [February 2, 2016, 11:36pm UTC](https://discuss.gradle.org/t/module-replacement-not-reflected-in-publication-metadata/14113/4 "2016-02-02T23:36:43Z")

</div>

That is the case. I just verified it with the following code:

```
configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.name == 'com.google.collections' && details.requested.name == 'google-collections') {
            details.useTarget group: 'com.google.guava', name: 'guava', version: '18.0'
        }
    }
}

```

I found [another discussion](https://discuss.gradle.org/t/maven-publish-doesnt-take-resolutionstrategy-into-account/1771) that references the same issue with `resolutionStrategy`.
