How can I customize the version of a sub project dependency that is placed in POM file?

I have a subproject (project-one) that is dependent on another subproject (project-two). The dependency is listed in project-two’s build.gradle as follows:

compile project(':project-one')

I am using gradle to publish these artifacts to Maven using the MavenDeployer and uploadArchives task. My projects use a versioning scheme (X.Y.Z.B[-SNAPSHOT]) that is different than what Maven expects (X.Y.Z[-SNAPSHOT]).

When generating the POM for each of the sub projects, within the MavenDeployer, I am able to set

pom.version = 'X.Y.Z[-SNAPSHOT]'

The problem is that, the project-two’s dependency on the artifact for project-one is being written to project-two’s POM using the X.Y.Z.B[-SNAPSHOT] versioning scheme instead of X.Y.Z[-SNAPSHOT].

Is there a way for me to override or manually set the version of a subproject dependency that is placed in the POM file?

You could use MavenPom.withXml() to modify the version number in project-two’s POM. May I ask why you are not simply using the value of project.version in the POM to begin with?

@mark_vieira Thanks! This worked for me.

Not using project.version in POM because that version has an extra component (X.Y.Z.B) that corresponds to the build number. The POM drops the build from the version so that multiple pushes are resolved to the same version as far as Maven is concerned (e.g. when pushing many snapshots during a development cycle).