Slackbot
04/26/2023, 2:33 PMAdam
04/26/2023, 2:40 PMconfigurations["intTestRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get())
Thomas Broyer
04/26/2023, 3:17 PMJohn
04/26/2023, 9:39 PMJohn
04/26/2023, 9:40 PMJohn
04/26/2023, 9:40 PMJohn
04/26/2023, 9:41 PMJohn
04/26/2023, 9:42 PMJohn
04/26/2023, 9:45 PMnamed("implementation"){
extendsFrom(configurations.named("adapter").get())
}
John
04/26/2023, 10:23 PMJohn
04/26/2023, 10:40 PMJohn
04/26/2023, 10:41 PMJohn
04/26/2023, 10:44 PMsourceSets{
val adapter by creating {
}
val main by getting {
kotlin {
compileClasspath += adapter.output
runtimeClasspath += adapter.output
}
}
val test by getting {
kotlin {
compileClasspath += adapter.output
runtimeClasspath += adapter.output
}
}
}
configurations {
val adapterCompile by getting
val adapterRuntime by getting
val mainCompile by getting{
extendsFrom(adapterCompile)
}
val mainRuntime by getting{
extendsFrom(adapterRuntime)
}
}
and i get
Configuration with name 'adapterCompile' not found.
Vampire
04/26/2023, 11:01 PM...Compile
and ...Runtime
were deprecated many many years and finally removed in Gradle 7.
You probably want adapterImplementation
and adapterRuntimeOnly
.John
04/27/2023, 12:00 AMconfigurations {
val adapterImplementation by getting
val adapterRuntimeOnly by getting
val implementation by getting {
extendsFrom(adapterImplementation)
}
val runtimeOnly by getting {
extendsFrom(adapterRuntimeOnly)
}
}
and still get the issue thoughJohn
04/27/2023, 12:59 AMtasks.named<Jar>("shadowJar"){
this.from(sourceSets.named("adapter").get().output.classesDirs)
}
John
04/27/2023, 12:59 AMAdam
04/27/2023, 7:11 AMProvider<T>
to a file provider Provider<File>
. That way Gradle can wire up the tasks properly. By using .get()
, Gradle will compute the value eagerly.
tasks.named<Jar>("shadowJar"){
this.from(sourceSets.named("adapter").map { it.output.classesDirs })
}
it’s not always possible to do this, because the Gradle itself isn’t fully compatible with the Provider API - hence why you have to use .get()
for the source set classpaths (e.g. runtimeClasspath += adapter.map { it.output }.get()
)Thomas Broyer
04/27/2023, 7:15 AMin adapter i want an interface, then i will add a different source set for each implementation, each compiled against a different version of a dependency, then i will choose which impl to use at runtime based on the version of the dependency on the classpathLooks like feature variants to me, except you don't want to rely on actual variants in dependency resolution (it's not that easy with plugins). But maybe you could use feature variants and arrange to bundle all variants in the same JAR?
Thomas Broyer
04/27/2023, 7:16 AM(this is a shadow jar artifact)If you're using the shadow plugin, then how about using distinct Gradle projects rather than source sets then? Would greatly simplify the setup IMO.
Adam
04/27/2023, 7:23 AMVampire
04/27/2023, 7:46 AMJohn
04/27/2023, 1:42 PMJohn
04/27/2023, 1:43 PMsourceSets {
val adapter by creating {
}
val main by getting {
kotlin {
compileClasspath += adapter.output
runtimeClasspath += adapter.output
}
}
val test by getting {
kotlin {
compileClasspath += adapter.output
runtimeClasspath += adapter.output
}
}
}
tasks.named<Jar>("shadowJar") {
this.from(sourceSets.named("adapter").map {it.output.classesDirs})
}
i guess i didnt need the block for configurations