How to distinguish task and extension with the same name?

I would like to ignore task from the plugin using ‘onlyIf’. Unfortunately I cannot use:

pitest {
   onlyIf { ... }
}

as ‘pitest’ is both a name of the task and a name of the extension and it fails with

MissingMethodException: Could not find method ignoreIf() for arguments [build_c9ls0ibyvdm4af6q42lpq2nza$_run_closure3_closure5@bb9379e]

I tried with ‘getTasksByName(“pitest”, true)[0] {}’, but it also fails.

How can I reference to the task not configuration closure when both have the same name?

1 Like

You can reference the task through the ‘TaskContainer’ interface via ‘project.tasks’. Just use ‘tasks.pitest’ instead of just ‘pitest’.

Thanks Mark, it helped.