Strange request, is it possible to get a platform’...
# plugin-development
c
Strange request, is it possible to get a platform’s dependency version? Say there’s a tool that takes a lazy string, how would I go about something like
Copy code
extension {
    version = configuraitons.oneOfThem.incoming.platforms.matching("spring-boot-dependencies").versionOf("some-sub-dep")
}
That way I lazily retrieve a sub-version of a bom
v
What a platform does, is setting dependency constraints. So maybe you can check the constraints? 🤷‍♂️
c
I was trying to dig into constraints but I'm unsure they're resolved unless they're actually used. I'll keep digging tho!
I was able to get it to work, but it had a cost: Resolving the whole configuration plus the dependencies you want the version of. I guess that's fine, I wanted that version anyways.
Copy code
val springBootDependencies by configurations.registering

dependencies {
    springBootDependencies(platform(("org.springframework.boot:spring-boot-dependencies:3.4.4")))
    springBootDependencies("org.jooq:jooq") {
        isTransitive = false
    }
}

tasks.register("springBootDependencies") {
    val version = objects.property<String>()
    version.set(springBootDependencies.map { config -> (config.incoming.resolutionResult.allDependencies.single { it.requested.displayName == "org.jooq:jooq" } as ResolvedDependencyResult).selected.moduleVersion!!.version })
    doLast {
        println(version.get())
    }
}