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

Hi,

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>() {
    @Override
    void execute(Sync t) {
        Configuration runtimeClasspath = getRuntimeClasspathConfiguration(project)
        t.dependsOn(runtimeClasspath)
        def artifact = runtimeClasspath.resolvedConfiguration
                .resolvedArtifacts
                .find { it.name.contains("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.