# Version in the "Publish" task dynamically

**URL:** <https://discuss.gradle.org/t/version-in-the-publish-task-dynamically/22242>\
**Category:** Help/Discuss\
**Created:** [April 6, 2017, 10:21am UTC](https://discuss.gradle.org/t/version-in-the-publish-task-dynamically/22242 "2017-04-06T10:21:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dominik](https://avatars.discourse-cdn.com/v4/letter/d/ee7513/32.png) [@Dominik](https://discuss.gradle.org/u/Dominik)\
**Post date:** [April 6, 2017, 10:21am UTC](https://discuss.gradle.org/t/version-in-the-publish-task-dynamically/22242/1 "2017-04-06T10:21:04Z")

</div>

I have a gradle which downloads a zip file. Then I unpack the file (this contains a jar and its dependencies). The version of the file is in a text file, which I read out. Now I want to put the library in an ivy repository.  
How do I get it to set the version only before the actual publish?

```
Version: unspecified wurde ermittelt!
:downloadfile
:generateDescriptorFileForIvyPublication
:publishIvyPublicationToIvyRepository
:publish

publications {
	ivy(IvyPublication) {
		descriptor.status = "release"
		module "ikit"

		File file = new File (buildDir, "revision.txt")
		if(file.exists()) {
			file.eachLine {
				revision it
			}
		} else {
			logger.error "File doesn't exists!"
		}

		descriptor.withXml {}
     }
  }
```
