Hi,
Using Gradle version 2.3
apply plugin: 'eclipse’
apply plugin: 'java’
apply plugin: 'maven-publish’
apply plugin: ‘com.jfrog.artifactory’
I’m trying to force a -Pversion parameter on the command line but only for the ‘publish’ task.
publish <<{
doFirst {
if (version.equalsIgnoreCase("unspecified")) {
println "If publishing, you must provide version parameter"
println "./gradlew -Pversion=#.#.# | ./gradlew -Pversion=SNAPSHOT"
System.exit(0)
} else if (version.equalsIgnoreCase('SNAPSHOT')) {
version='SNAPSHOT'
} else {
println "Building RELEASE version ${version}"
}
println
println "************************************"
println "* Building version ${version} "
println "************************************"
println
}
}
However, # sh gradlew -x test publish
goes and ahead and publishes everything with ‘unspecified’ as the version. Nothing from the block above is printed.
If I put the block outside of the publish block, it works but it obviously applies to all tasks.