How can I access configurations.runtime in a custom task class using Kotlin DSL

I’m working on my first Gradle plugin and I’m running into an issue here.

The plugin should copy all dependencies to the lib directory.

When I implemented this directly in the build script it works fine.

task<Copy>("copyToLibs") {
    dependsOn("cleanLibs")
    
    from(compile)
    into("lib")
}

I would like to put this into a Gradle plugin.

open class CopyToLibTask : Copy() {

    init {
        group = "myFirstPlugin"
    }

    override fun copy() {
        from(????) // What should be put here?
        into("lib")
    }
}

I tried to just use compile, but that didn’t work.
On other pages I found something like configurations.runtime, but that doesn’t work either, since it doesn’t know configurations
Finally I tried project.configurations.runtime. Here I got as far as project.configurations, but runtime is not known.

Could someone help me out here?

Did you try project.compile? I have the feeling that is a task simply returning resulting files.

Hi Thorsten,

I just did, but that gave me “Unresolved reference: compile”

open class CopyToLibTask : Copy() {

    override fun copy() {
        from(project.compile) // gives "Unresolved reference: compile"
        into("lib")
    }
}