How to disable using "Gradle Module Metadata", then to use pom.xml to resolve dependencies

Hi,

In resolving dependencies from Maven repositories, I wanted to disable using “Gradle Module Metadata”, and wanted to use pom.xml. Is it possible in Gradle?

Note that what I wanted is not disabling Gradle Module Metadata publication. I wanted to disable resolution.

Context

I have published some Maven artifacts to a (local) Maven repository, with tweaking their pom.xml. I expected that the tweaked pom.xml are used when building a Gradle project depending on the artifacts. But actually, their untweaked “Gradle Module Metadata” are used, and my build didn’t go as expected.

I know that re-publishing those Maven artifacts with disabling to publish “Gradle Module Metadata” would resolve the problem, but there are many artifacts published. I wanted to avoid re-publishing all.

Instead, I am wondering if I could just ignore those “Gradle Module Metadata” that have been unintentionally published in the Maven repository when building the local Gradle project.

Is it possible?

Yes, you can disable it per repo declaration like:

repositories {
    maven {
        url = ...
        metadataSources {
            ignoreGradleMetadataRedirection()
        }
    }
}

And for the future, it is almost always a bad idea to ignore the metadata or to not publish it. It has a much richer model than poms and thus leads to much better resolution. Better fix the configuration of your build so that the metadata you need is generated and then this should usually also generated according pom.

3 Likes

Thanks. It worked!

I understand that the Metadata would be usually better in general, but we don’t go with it. It’s because the framework that we build expects Maven’s nature, not only in building/compiling, but also everywhere.

I know it’s a special case, so I’m not saying that Gradle’s Module Metadata is a bad thing.

1 Like