How can I use the resolved version of a dynamic version dependency in a subproject in my aggregate-all javadoc task?

Assume a subproject which declares a dynamic version dependency:

dependencies {
    implementation "org.examble:foo-lib:[1.0.0, 1.0.999]"

within the root project, I have a javadocAll task, which aggregates the javadoc of all subprojects. Here I want to link to foo-lib’s javadoc:

javadoc {
    options {
        links = [

I experimented a bit a got

def getResolvedVersion(queriedProject = ':my-subproject', component) {
	def configuration = project(queriedProject)


	def artifact = configuration
		.find {
			// 'it' is of type ResolvedArtifact, 'id' of
			// Component*Artifcat*Identifier, and we check the
			// ComponentIdentifier. instanceof org.gradle.api.artifacts.component.ModuleComponentIdentifier
                           && + ':')


But artifact is (often?) null, even though the configuration is in state RESOLVED. I guess this is because the subproject was not yet in its configuration phase when getResolvedVersion() was invoked (which is, I assume, during the root projects configuration phase).

getResolvedVersion was based on the answer provided by my related SO question