Create partial fat plugin jar containing local modules

I have a multi-module project set up that creates a gradle plugin. I have a couple modules that are treated as libraries (and which I export separately), and a couple of modules using those libraries to produce custom plugins. I want to create a partial fat jar of ONLY the local modules and the plugin module. I am able to create this jar (using the shadow plugin or the jar task), but what I am not able to do is then execute tests. No matter what combination of dependency configurations I try, the tests are always missing the library module classes, and fail with ClassNotFoundException. What am I missing that can resolve this?

plugins {
    id("com.github.johnrengelman.shadow") version "8.1.1"

val libraries: Configuration by configurations.creating

dependencies {



    libraries(project(":base")) {
        isTransitive = false

tasks {
    test {

    shadowJar {
        configurations = listOf(libraries)

Imho you should not do it.
If you split it into multiple projects, then publish each module and have normal dependencies.

But I think if you make testRuntimeOnly.extends(libraries) you should get your test issue solved.