How to Dynamically set Revision for Ivy Publish

I am trying to create an Ivy Publication in a subproject with a dynamic revision based upon the version property of the root project. So far, the revision is always unspecified and I cannot find a way to set the revision.

I’m new to using Gradle so I’m hoping there is a simple solution I am unaware of. BuildVersion is getting run but nothing I’ve tried has set the revision. Here is the subproject script I am using. I’m not including any of the things I’ve tried that haven’t worked.

apply plugin: ‘ivy-publish’

task sourceJar(type: Jar) {
     from sourceSets.main.java
     classifier "source"
}

publish.dependsOn rootProject.buildVersion

publishing {
     repositories {
     ivy {
         url "${rootProject.buildDir}/repo"
         layout 'ivy'
     }
 }
 publications {
     ivy(IvyPublication) {
         organisation 'com.test'
         module 'test'
         revision rootProject.version
         from components.java
         artifact(sourceJar) {
             type "source"
             conf "default"
         }
     }
 }

}

This was the solution I came up with.

task setIvyRevision {
doLast {
publishing.publications.ivy.revision rootProject.version
}
}

Then I just have to make sure setIvyRevision happens before publish and it works.