Resolve project from other build (composite) - ForeignBuildIdentifier

Hey guys. I am trying to copy the sources jar from references project dependencies. This works ok for projects from the current build:

  tasks.findByPath("sourcesJar")?.also { sourcesJarTask ->
    sourcesJarTask.outputs.files.files
      .forEach {
        return it;
      }
  }

But how can I do this for projects from composite builds? All I get from my artifact resolution query is a ForeignBuildIdentifier. But how can I get a hold to the projects from the other build?

More code to (maybe) understand better, what I am doing:

      val incoming = configurations.runtimeClasspath.get().incoming

      val componentIds = incoming.resolutionResult.allDependencies.map {
        val resolved = it as ResolvedDependencyResult
        val selectedId = resolved.selected.id
        selectedId
      }.toList()

      val result = dependencies.createArtifactResolutionQuery()
        .forComponents(componentIds)
        .withArtifacts(JvmLibrary::class, SourcesArtifact::class)
        .execute()

      result.components.forEach {
        if (it is UnresolvedComponentResult) {
          val projectId = it.id as ProjectComponentIdentifier

          if (!projectId.build.isCurrentBuild) {
                 //What do to do here?
          }