Use resolved version in Gradle module metadata

Our dependencies are specified with a textual key where we apply a resolution strategy to assign the appropriate version to resolve. For example, in the dependency notation we have ‘dependency.version’ that is resolved to a specific version, ‘2.2.3’.

Using the Maven publication, we ensure that resolved versions are published to the pom file using:

versionMapping {
  versionMapping {
    allVariants {
      fromResolutionResult()
    }
  }
}

However, the generated module metadata has the literal version string, rather than the actual version as desired, something like:

{
  "group": "org",
  "module": "dependency",
  "version": {
    "requires": "dependency.version"
  }
},

How can the module metadata be configured to use the resolved version instead?