# How to Dynamically set Revision for Ivy Publish

**URL:** <https://discuss.gradle.org/t/how-to-dynamically-set-revision-for-ivy-publish/17682>\
**Category:** Help/Discuss\
**Created:** [May 20, 2016, 3:47pm UTC](https://discuss.gradle.org/t/how-to-dynamically-set-revision-for-ivy-publish/17682 "2016-05-20T15:47:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dbickler](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@dbickler](https://discuss.gradle.org/u/dbickler)\
**Post date:** [May 20, 2016, 3:47pm UTC](https://discuss.gradle.org/t/how-to-dynamically-set-revision-for-ivy-publish/17682/1 "2016-05-20T15:47:58Z")

</div>

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"
         }
     }
 }

```

}

---

<div class="post-metadata">

**Author:** ![dbickler](https://avatars.discourse-cdn.com/v4/letter/d/c68b51/32.png) [@dbickler](https://discuss.gradle.org/u/dbickler)\
**Post date:** [May 26, 2016, 9:01pm UTC](https://discuss.gradle.org/t/how-to-dynamically-set-revision-for-ivy-publish/17682/2 "2016-05-26T21:01:32Z")

</div>

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.
