The stand-alone JUnit5Plugin has a
compile dependency on
This works great when building the
JUnit5Plugin, since this brings in the
ConsoleRunner used by the plugin as well as other mandatory transitive dependencies.
However, the custom task created by the plugin also requires these same dependencies (as runtime dependencies only), but they are not associated with the task by default.
So, as a work-around, we are currently doing the following when applying the plugin.
// Ensure that the ConsoleRunner is on the classpath project.dependencies.add("testRuntime", "org.junit:junit-console:5.+")
This works, but it’s ugly for the following reasons.
- We don’t want to hard-code any version information into the plugin’s source code.
- We would prefer to automatically add all of the plugin’s dependencies to the classpath of the custom task when it executes.
- We don’t actually want to add anything to the project’s dependencies if not absolutely necessary.
Sooooo, how can we achieve this in Gradle?
Any tips would be greatly appreciated!