How to apply custom plugin I am developing in gradlerrunner

I want to test applying my custom plugin in a test, but every time I do it says it can’t find it. In the example it shows applying a plugin that already exists. How do I apply it if it only exists locally in my project?

Yes, this is one of the “messy” things about testkit that I’m hoping is cleaner to do in future (Jacoco bootstrapping is the other “messy” thing)

See here where I create a testkit-classpath.txt file and add the folder to the testRuntime configuration. And here where I read the testkit-classpath.txt and bootstrap the gradle build with it.

This could also be done using system properties instead of a file but I prefer file based approach because I can run in my IDE without needing gradle (assuming I’ve run once in gradle first)

Please refer to the section Automatic injection with the Java Gradle Plugin Development plugin in the user guide. Make sure that your GradleRunner instance calls the method withPluginClasspath(). The build script under test must use the plugin DSL to apply your plugin under test.

@Lance Can you explain what you find “messy” about the approach? It requires very little configuration. Are you just referring to the integration with JaCoCo?

I created an issue regarding the integration with JaCoCo. Contributions welcome!

I tried GradleRunner.withPluginClasspath(...) initially but it wasn’t working. After looking at the example I think my problem was using apply plugin 'x' instead of plugins { id 'x' }

I’ve just made a change here to remove my manual testkit classpath config and instead use java-gradle-plugin and GradleRunner.withPluginClasspath(). It’s much cleaner now

I am planning to state the mandatory configuration more clearly in the user guide: https://github.com/gradle/gradle/issues/1231