Using classes instead of jar: how to ensure the jar exist?

I have a build which add multiple subprojects, one of those projects bundles the jars from other projects into a distribution and expresses this dependency as a project dependency via the api configuration.

The bundling task includes the binaries are specified by the runtimeClasspath configuration (via resolvedConfiguration.resolvedArtifacts specifically).

This feature means that just adding that dependency does not ensure the jar exists.

The only way I can think of ensuring this happens is searching for the jar tasks across the entire project and adding a mustRunAfter dependency from the bundling task. This seems rather clumsy . Is there a better way to express that dependency? i.e. to depend on the packaged form of the dependency only

The solution here is to use the Configuration as an input to the task (annotated as @InputFiles)

The problem is that I need information about the artifact that produced each file to generate some other metadata so currently have to also add the configuration name as an input. Is there a way to use a Configuration as an @InputFiles but still have access to that additional metadata?