Custom Gradle plugin runtime dependencies

I’m making a gradle plugin that has some runtime only library dependencies. These dependencies are included in the plugin’s pom like I would expect, but when adding the plugin to a project via the plugins dsl, these runtime only dependencies aren’t being included unless I explicitly add them to buildscript dependencies.
I’m pretty new to Gradle, so any advice would be appreciated.
Compile dependencies are working as expected.

In my plugin:

dependencies {
  implementation("com.badlogicgames.gdx:gdx-backend-headless:$gdxVersion")
  runtimeOnly("com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop")
}

(It doesn’t matter if the runtimeOnly dependency is implementation, compile, or runtimeOnly, it’s not in the classpath when using the plugin)

In the project using the plugin:

plugins {
	id("com.example.myplugin")
}

buildscript {

	dependencies {
		val gdxVersion = "1.9.10"
		// If I don't list this runtime dependency explicitly, the plugin won't work as the 
		// natives won't be on the classpath:
//		classpath("com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop")
	}
}
1 Like

I never solved my problem, but here’s the workaround I did for posterity:

Ran the code I needed that had runtime dependencies as a JavaExec task, setting the classpath to a custom configuration.