Can plugins with JavaExec tasks add code from the plugin itself to the classpath?

My plugin defines a JavaExec tasks. It adds the “runtimeClasspath” of the main source set, and the “compileClasspath” and “.getOutput()” of a source set the plugin creates in the project.

I also want src/main/groovy from the actual plugin code itself to be added to the classpath. Since the plugin is a “buildscript” dependency, it is not present in the runtimeClasspath of the main source set.

How do I add the plugin itself to the classpath of my JavaExec task?

Here’s my code so far. https://gist.github.com/augustl/c0fdf2c7ce9e388c22c6

Figured it out on my own.

To access the classpath of the plugin, use ‘project.buildscript.configurations.classpath’.

This is not really the classpath of the plugin, it’s the classpath of the entire buildscript step. But that’s where my plugin lives, so it shouldn’t be a problem for me to use that classpath.