(Note: I’m using gradle 1.10 and the new Maven Publishing as described in chapter 65. )
I would like to prevent the publishMavenJavaPublicationToMavenRepository task to run if some condition is met. Checking the condition and preventing the build task to run is working fine:
build.onlyIf{
myCustomUpToDateCheck.isBuildRequired()
}
But it does not work with the publish task. So I also tried with a rule:
tasks.addRule("Pattern: publishMavenJavaPublicationToMavenRepository: do not publish if repo artifact is up-to-date."){ String taskName ->
if( taskName == "publishMavenJavaPublicationToMavenRepository"){
task(taskName).doFirst {
if(!myCustomUpToDateCheck.isBuildRequired()){
logger.quiet "Stopping execution of ${taskName} for ${project.name} since build is not required"
throw new StopExecutionException()
}
}
}
}
What did I do wrong ? Is it possible at all to prevent the publish task from running ?
Background information:
The reason for the custom up-to-date check is: - sources are generated as part of a central code-generation infrastructure - build is run automatically - but components which did not change (comparing local and remote revision, stored as metadata in maven pom) must not be uploaded