Reputation: 1140
I am trying to create an Ivy Publication in a subproject with a dynamic revision based upon the version property of the root project which is also set dynamically. 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 sets the version of the root project. It is getting run but nothing I've tried has set the revision with it. 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"
}
}
}
}
Upvotes: 0
Views: 456
Reputation: 341
Not an answer per se, but I don't have the rep to comment!!
Been working on something similar myself. My setup is slightly different in that I use Jenkins to run Gradle and trigger deployment of Ivy-format artifacts to Artifactory. Anyway, I found that the Jenkins plugin uses project.version as the revision so have been setting that within Gradle.
Guessing I'm as new as yourself to this, but just in case it helps you...
Update: Given the comments, the following will allow you to defer the setting of the ivy revision until the execution phase:
tasks.create(name: 'preTask') {
doLast {
// put execution phase code here
}
}
tasks.create(name: 'Task') {
dependsOn preTask
publishing.publications.ivy.revision rootProject.version
}
Upvotes: 1