Exposing a custom configuration

Hi,

I’m using Gradle 5.6.2 and the Gradle Kotlin DSL.

In my buildSrc for a multi module project, I have declared a custom plugin which declares a custom configuration:

            val javaConvention = target.convention.getPlugin(JavaPluginConvention::class.java)
            val sourceSets = javaConvention.sourceSets
            sourceSets.create("dsl")

            val dslImplementation by target.configurations.getting

            target.dependencies {
                dslImplementation(project(":dsl-model"))
            }

            val dslJar by target.tasks.registering(Jar::class) {
                archiveClassifier.set("dsl")
                from(sourceSets["dsl"].output)
            }

            target.tasks["assemble"].dependsOn(dslJar)

This works fine for a given module and the DSL JAR is correctly built, with the correct dependencies.

However, if I want to use this module from another one in the same project:

dependencies {
   implementation(project(":dsl-module", "dsl"))
}

I get the following error on assemble:

Project :dsl-consumer declares a dependency from 
configuration 'implementation' to configuration 'dsl' 
which is not declared in the descriptor for project :dsl-module.

So I wonder, how can I declare a custom configuration in a module and somehow make it
available for consumption in other modules?

Thanks for any suggestion,
Damien

Here is what I did to fix the issue.

Additionally to the setup described above, I’ve declared the artifact of the module to consume:

val dslConfig by target.configurations.creating
target.artifacts {
    add("dslConfig", dslJar)
}

and I refer to this configuration in the client:

dependencies {
   implementation(project(":dsl-module", "dslConfig"))
}

Simple enough, but TBH, not easy to find information about this.

Best regards,
Damien