I have a project with multiple subprojects, and am simplifying their build scripts.
To keep things simple, I’ll use a much simplified example.
There are two versions of a Java library, each with their own subproject, say java:he
and java:ee
. There are two versions of a Graal VM-using C library, which uses the outputs of the Java library process as input, c:he
and c:ee
.
The build scripts are complex, but the core logic is effectively identical between the he
and ee
versions. The core logic is extracted to a plugin (let’s call it cbuild
) shared by both c:he
and c:ee
versions. What differences there are, are handled by applying and configuring the plugin.
The issue I’m having is that I want to depend on artifacts of the correct java:_e
version in the cbuild
plugin, and that is set by configuring the plugin’s extension like so:
# c/he/build.gradle.kts
plugins {
id("cbuild")
}
cbuild {
edition = "he"
}
The java:he
project has defined a consumable configuration containing its source files, javaSources
.
In the cbuild.gradle.kts
plugin file I have this:
interface CBuildExtension {
abstract val edition: Property<String>
}
val extension = project.extensions.create<CBuildExtension>("cbuild")
val javaSources by configurations.dependencyScope("javaSources")
dependencies {
javaSources(project(mapOf(
"path" to extension.edition.map { ":java:${it}" },
"configuration" to "runtimeElements"
)))
}
Needless to say, this does not compile.
Is there a mechanism I can use to achieve this, or do I need to declare it explicitly in a dependencies block in c/he/build.gradle.kts
?
Thanks!