Accessing classes from settings.gradle

We recently upgraded to Gradle 6.0 in order to get support for Java 13 (Thank you!). I know that there have been changes in the way the buildSrc directory is handled and, in particular, that code from that directory is no longer accessible from the settings.gradle file. We have some custom build logic that we use for including projects in our multi-module build, which we bundle up in our plugins jar. This jar is added as a buildscript dependency in the settings.gradle file. This works great until we need to make updates to our plugins. I had previously been using the buildSrc directory as a way to develop and test changes to our local plugins without having to publish them each time or even build the jar individually, since that was done automatically, but this no longer works because when the dependency to the plugin jar is added in the settings.gradle file, all projects inherit that dependency and so nothing sees the changes made in the buildSrc directory.

I have been able to change my dependency declaration in the settings.gradle file to point to the jar in the build/lib directory for my local plugins enlistment, so this could work, but it’s a little inconvenient. I could get used to having to manually build the jar file, but for some reason I now have to declare some of the implementation dependencies from my plugin within that dependencies block in the settings.gradle file. This isn’t required when the dependency is on the published jar file.

I have tried to factor out the logic used in the settings file and this works as long as I put the methods and/or classes I want directly in the settings file. I had hoped to be able to put these in a utilities.gradle file that I then incorporate with
apply from: 'utilities.gradle'
I can see that the methods and classes defined in that file do get compiled, but I’m having no luck actually referencing them from the settings file. Even if I get this to work, it’s still not ideal as I believe I will have to duplicate some of these utility methods since some of them are also used outside the settings.gradle file.

I could publish a separate plugin that has just these utility methods and/or classes, but if I need to make changes to those methods I’ll still be in sort of the same boat

So, three questions:

  • Is there a recommended pattern for developing and testing plugins locally that does not involve publishing or separately building the jar file (and then declaring some of the dependencies again)?
  • How should I reference functions or classes that are compiled in a separate file and then incorporated into a settings.gradle file via “apply from:”
  • Is there a way to have the settings file declare a dependency on the plugin without its being inherited by all the projects (so I can use the buildSrc directory for developing changes to my plugins)?

Any suggestions or pointers to documentation that I may have missed would be appreciated.

Thanks!

Susan