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

Groovy DSL is missing an equivalent invoke on NamedDomainObjectContainer #7350

Open
JLLeitschuh opened this issue Oct 11, 2018 · 3 comments
Open

Comments

@JLLeitschuh
Copy link
Contributor

JLLeitschuh commented Oct 11, 2018

In Kotlin, there's this extension:

/**
 * Allows the container to be configured via an augmented DSL.
 *
 * @param configuration The expression to configure this container with
 * @return The container.
 */
inline operator fun <T : Any, C : NamedDomainObjectContainer<T>> C.invoke(
    configuration: NamedDomainObjectContainerScope<T>.() -> Unit
): C =

    apply {
        configuration(NamedDomainObjectContainerScope(this))
    }

So if I have an extension like this:

open class JlinkExtension
@Inject
internal constructor(
        project: Project
) {
    val linkOptions: NamedDomainObjectCollection<JLinkOptions> = project.container(JLinkOptions::class.java) { name ->
        JLinkOptions(name = name)
    }
}

In Kotlin, I can do this:

jlink {
    linkOptions {
        // Do whatever
    }
}

However, doing the same in Groovy results in this:

* What went wrong:
A problem occurred evaluating root project 'plugin-test'.
> Could not find method linkOptions() for arguments [build_5cmd5e1u8kv2rtq3aoi5hpenx$_run_closure1$_closure2@35652977] on object of type edu.wpi.first.desktop.jlink.JlinkExtension.

This is confusing for plugin authors, because they think when they are exposing a NamedDomainObjectContainer they are not exposing the ability to configure it the same way as groovy allows it to be configured.

Steps to Reproduce (for bugs)

In a plugin, just register the above provided JlinkExtension as an extension.

Your Environment

------------------------------------------------------------
Gradle 4.10.2
------------------------------------------------------------

Build time:   2018-09-19 18:10:15 UTC
Revision:     b4d8d5d170bb4ba516e88d7fe5647e2323d791dd

Kotlin DSL:   1.0-rc-6
Kotlin:       1.2.61
Groovy:       2.4.15
Ant:          Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM:          1.8.0_92 (Oracle Corporation 25.92-b14)
OS:           Mac OS X 10.13.6 x86_64

@stale
Copy link

stale bot commented Aug 5, 2020

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Aug 5, 2020
@stale
Copy link

stale bot commented Aug 26, 2020

This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to reopen the issue with steps to reproduce, a quick explanation of your use case or a high-quality pull request.

@stale stale bot closed this as completed Aug 26, 2020
@eskatos eskatos reopened this Sep 8, 2020
@stale stale bot removed the stale label Sep 8, 2020
@stale
Copy link

stale bot commented Apr 13, 2022

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Apr 13, 2022
@eskatos eskatos removed the stale label Apr 13, 2022
@ov7a ov7a added the a:bug label Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants