Acquire Plugin Resource (Rather than Consuming Project) by Plugin

I can make this work with the java-gradle-plugin but I would prefer the kotlin-dsl
to make the plugin.
The difficulty is in how to get a handle to a plugin resources at runtime.
The layout.projectDirectory.dir("src/main/resources") pulls in the resources of the project using the plugin and not the resources associated with the plugin itself.

The approach I found was to move the logic for reading the resource in the custom task rather than the plugin. Such as in the following:

abstract class FooTask : DefaultTask() {
    abstract val scriptName: Property<String>
    fun exec() {
        val scriptUrlStream = javaClass.classLoader.resources(scriptName.get())