How to apply custom resolution to pom generation

In order to centralize declaration of dependencies in our multi-project build, I replaced the actual version for many 3rd party dependencies with ‘default’. Along with that, I defined a custom resolution strategy that watches for ‘default’, looks up the correct version, and substitutes it. So far, so good. But the generated pom files use ‘default’, which causes later stages of the build to break because there is no such version as ‘default’ for them to download. What does it take to apply the same swapped version to the generation of the POM file?

thank you for any help

There’s no simple built-in mechanism to do this, however this is a very similar use case as GRADLE-1663. The linked issue contains a solution (albeit for ivy) that could be adapted pretty simply to what you are trying to do.

Thank you, I’ll try that.

In trying to come up with a MavenPublication version of this, the main block is that the dependency objects that I get are read-only, even when they are of type ResolvableDependency. Walking through the project configurations (within pom.withXML), getting their dependencies, finding the ones that use ‘default’, looking up the correct version, and setting it there hits that error. Simply repeating the code that sets the custom resolution strategy, but doing so within pom.withXml, doesn’t help either. What is the Ivy example doing that enables it to set the version and have it apply to the generated xml file?

thank you for any help

I got the same problem (only we are using empty version instead of “default”). Currently overriding the version directly in the POM spec, but would have appreciated an easy way to enforce the resolved versions if the declared version is empty.