Task name abbreviation and startParameter.taskNames


(Jun Wang) #1

Hi everyone,

I am writing a Gradle plugin, it provides some tasks. I want to do add a finalizer to one of those tasks when a specific task is invoked, I am using startParameter.taskNames to get the name of the invoked the task, but it is not working when people use abbreviated task names. Any ideas how to achieve it? Many thanks!


(Peter Niederwieser) #2

Add the finalizer task unconditionally. If you really need to prevent it from running if some other task isn’t invoked (which seems odd at first), add ‘myTask.onlyIf { gradle.taskGraph.hasTask("$project.path:otherTask") }’.