How to make plugin dependent on gradle task

I have added plugin
id “com.github.spacialcircumstances.gradle-cucumber-reporting” to generate cucumber html reports , But I want it to run only when i execute cucumber task .this plugin calls generateCucumberReports task which runs automatically at the end of test task, I know the way to skip report generation using -PskipReports but this I need to pass from console everytime I run different task.

Is there anyway so that this plugin work only when cucumber task is call.

Thank you

can anyone please help?

Plugin may have an option to skip dependency registration (make pull request with fix if not!).

And then you can add dependencies as usual:




If you can’t change plugin source code try onlyIf

Thank you, it was helpful to resolve my issue.