How to apply clover plugin in Multi project setup in right way

We have multi project setup and are using clover plugin for code coverage of Java process. the sub projects are written in Java and Scala. When I apply the clover plugin in build.gradle of root project and run the unit test, the clover plugin is also applied on subprojects which are in Scala and as a result it fails. I dont want to manually update the build.gradle of all the subprojects

Can someone suggest a way of resolving it

Note: I have enabled the clover plugin at the build.gradle at root level and in those subprojects which are written in Java

I should have asked first for clarification.
Which Clover plugin are you using? The OpenClover provided one?

As I am the current maintainer of the Clover plugin for Gradle I am interested in finding the answer for you. I am surprised that you say the plugin is applied to Scala projects. The plugin does not automatically apply itself at any point so I will need to investigate what this problem is and how to workaround.

I tried to reproduce the problem with a trivial Java project and the Scala quickstart project from the Gradle 4.7 samples. I placed the trivial Java project and the quickstart project as sibling projects in a multiproject configuration. I enabled clover plugin at the root project and added the same in the java project. I was able to build everything combined and produce Clover reports for the Java project and had no issues with the quickstart project building at the same time.

If you can provide an illustration of the problem in a simple build.gradle file would expedite finding the answer.

Thanks for looking into the issue.

I did further investigation and found that since my firm has created tasks around clover plugin it was behaving in that way

I tried to directly use the clover plugin but it failed with error that it could not find license file. I tried with explicitly setting license file but still it didnt help.

For now I have created task which dynamically applies the plugin on all projects (where it is not required) and disabled the clover tasks

You are not using a current version of the Clover plugin. The latest version uses OpenClover which is no longer requiring a license. The plugin required a license file to be located in the filesystem in versions prior to 2.2.0 I think. You should be using 2.2.0 or later at this point.