Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Action<T> instead of Closure in API (e.g. ProjectPackagingExtension) #399

Open
vlsi opened this issue May 16, 2021 · 1 comment
Open

Comments

@vlsi
Copy link

vlsi commented May 16, 2021

Sample:

CopySpec from(Object sourcePath, Closure c) {
use(CopySpecEnhancement) {
return getDelegateCopySpec().from(sourcePath, c)
}
}

It causes Kotlin DSL usages look awkward:

from("${pack}/bin", closureOf<CopySpec> {
    into("${dest}/bin")
    fileMode = 0x168
})

If the method was declared with Action<CopySpec> c, then both Groovy DSL and Kotlin DSL would be ok.

    CopySpec from(Object sourcePath, Action<CopySpec> c) {
        ...
    }

See https://docs.gradle.org/current/userguide/groovy_build_script_primer.html#delegation

All new Gradle APIs declare an Action argument type rather than Closure, which makes it very easy to pick out the delegate type. Even older APIs have an Action variant in addition to the old Closure one

@chali
Copy link
Member

chali commented May 19, 2021

Hi @vlsi thank you for the issue. I think it makes sense. Unfortunately, our priorities don't allow us to pick up this work at this moment. Would you be willing to provide a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants