Ivan CLOVIS Canet
06/29/2025, 6:55 PMdependencies {
dokka(projects.a)
dokka(projects.b)
kover(projects.a)
kover(projects.b)
nmcpAggregation(projects.a)
nmcpAggregation(projects.b)
// …
}
which is not fun to maintain when there are dozens of projects.
Instead, I'd rather have:
dependencies {
library(projects.a)
library(projects.b)
}
where library
is a custom configuration that applies its contents to dokka
, kover
and nmcpAggregation
.
I've tried:
val library by configurations.registering {
isCanBeResolved = false
isCanBeConsumed = false
}
configurations.dokka.get().extendsFrom(library.get())
configurations.kover.get().extendsFrom(library.get())
configurations.nmcpAggregation.get().extendsFrom(library.get())
but that only seems to partially work.
I'm testing it in a build that looks like
Root project 'Kotlin-example'
+--- Project ':app'
+--- Project ':core'
+--- Project ':mkdocs'
\--- Project ':plugin'
where the root project contains
dependencies {
library(projects.core)
}
The NMCP plugin seems to pick up the dependency:
$ … dependencies --configuration nmcpAggregation
nmcpAggregation
\--- project :core FAILED
However, the Kover configuration gets the current project for some reason:
$ … dependencies --configuration kover
kover (n)
\--- project Kotlin-example (n)
And the Dokka plugin doesn't get anything at all:
$ … dependencies --configuration dokka
dokka - Fetch all Dokka files from all configurations in other subprojects. (n)
No dependencies
What's going on? If extendsFrom
isn't the correct way to do this, what is?Philip W
06/29/2025, 7:28 PMMartin
06/29/2025, 9:34 PMephemient
06/30/2025, 12:54 AMisCanBeResolved
and isCanBeConsumed
Vampire
06/30/2025, 1:54 AMyou should ideally use configurations.dependencyScope insteadWhich is still
@Incubating
though and thus many people refuse to use it already. 😉Vampire
06/30/2025, 1:55 AMdependencies
output.Vampire
06/30/2025, 1:56 AMdokka
and kover
are not resolvable, so you only see the dependencies declared directly on them and that's it.
If you create a resolvable configuration that extends from dokka
it will contain the dependency for example.Vampire
06/30/2025, 1:57 AMval library by configurations.dependencyScope("library")
val resolvable by configurations.resolvable("resolvable") {
extendsFrom(library)
}
val nonResolvable by configurations.dependencyScope("nonResolvable") {
extendsFrom(library)
}
val resolvableNonResolvable by configurations.resolvable("resolvableNonResolvable") {
extendsFrom(nonResolvable)
}
dependencies {
library(project)
}
And you will see
library (n)
\--- project showcase (n)
nonResolvable (n)
No dependencies
resolvable
\--- root project : (*)
resolvableNonResolvable
\--- root project : (*)
Ivan CLOVIS Canet
06/30/2025, 6:56 AMnmcp
in repository <https://gitlab.com/opensavvy/automation/gradle-conventions.git>
, more specifically the latest commit. The test project is available with ./gradlew -p examples/kotlin --include-build ../.. tasks
, that repository is a bit of a mess.Ivan CLOVIS Canet
06/30/2025, 7:04 AMIvan CLOVIS Canet
06/30/2025, 7:04 AM