Custom plugin, how to resolve a single dependency from the consuming project and extract files from it


I am building a Gradle plugin that needs to extract some files as inputs for some of it’s tasks. The files required are found within an api dependency within the consuming project’s build.gradle.

My current code tries to resolve the runtimeClassPath configuration and supply an artifact to a Sync task.

 // Configure task to import data
importTask.configure(new Action<Sync>() {
    void execute(Sync t) {
        Configuration runtimeClasspath = getRuntimeClasspathConfiguration(project)
        def artifact = runtimeClasspath.resolvedConfiguration
                .find {"model-data") }
        t.with(createImportModelResSpec(project, artifact.file))

I can get this to work by creating a custom configuration, rather than the runtimeClasspath, but am not keen on going down that route due to the dependency version being defined in the plugin source code rather than the consumeing projects build.gradle.

What is the correct way to achieve what I am trying to do?

P.S. I hope this makes sense.