What is the idiomatic place to put path configurations added by custom plugins?

Hello, I’m currently writing a plugin adding a couple of tasks common to a number of projects
(mainly generating zips with a particular structure).

I use those to package files that are, conceptually resources - but do not belong into the resources sourceSet because they are not to be packaged with the jar task, nor are they supposed to be visible to running tests. I want to make the path these resources are located at configurable, but I am not sure what the most ‘gradle’ way to do this would be.

I’ve thought about adding another ‘kind’ of source directory to sourcesets, so I could say

sourceSets {
  main {
    myResources.srcDirs = ['src/main/myResources']
  }
}

I’m not entirely sure how I would go about doing that, but since there are open source plugins with this behavior it shouldn’t be too hard to find out. I’m just somewhat concerned this isn’t the right way; For instance, having test myResources doesn’t really make any sense (because these only become relevant on deployment).

I could also just make the directory configurable with a global, so the using buildscript would have a line

myResourcesDir = 'src/main/resources'

But I’m not sure if adding globals like that is a good idea. Can anyone point me to best practices on doing configuration like this? When I searched online I mostly found topics on how to adjust the scope of the existing resources sourceSet, which isn’t that useful to me.

Depending on how many properties you have, the typical way of having plugin level configuration is through an Extension class:

https://docs.gradle.org/current/userguide/custom_plugins.html#customPluginWithConvention

HTH