Version in the "Publish" task dynamically


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!

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