Apply plugins provided from convention plugins conditionally

Hello

what would be the recommended way to apply plugins conditionally.

Say I have a set of convention plugins and those plugins configure other plugins e.g

plugins {
  id 'maven-publish'
  id 'io.freefair.lombok'
  id 'com.jfrog.artifactory' //baaad plugin
  id 'project-report'
}

So now I might not need the artifactory plugin in every project that uses this convention plugin.
Is there a (recommended) way to enable client projects (e.g. which never should be published to artifactory) of this convention plugin to prevent the configuration of certain plugins (say the artifactory plugin in this case) at all?

Or is it even a best practice to create multiple convention plugins and in this case one that only provides the artifactory stuff so that client projects only apply this convention plugin when needed?

Thx.
Rob

There are multiple ways.

Providing a condition of whether to apply the plugin from the consumer project is not really cleanly possible.

But having separate convention plugins is one way, yes.

Another would be, that the consumer project applies the arifactory plugin if it needs it and your convention plugin just configures it if it is applied using pluginManager.withPlugin(...) { ... }.