groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo zhang <zhangbo...@gmail.com>
Subject Re: How to determine the equality of two closures?
Date Thu, 13 Apr 2017 14:22:59 GMT
Thanks for your reply.

Actually, I'm writing a Gradle plugin in which I want to apply Gradle's
up-to-date check
<https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:up_to_date_checks>
and treated some closures as task input. That is to say, if a user-defined
closure in build.gradle doesn't change between two builds, I can consider
the task as "up-to-date" and skip them.

For example, a user writes a configuration block in build.gradle:

...
someConfiguration {
     "That is my closure"
}
...

As long as that closure doesn't change, the task depending on it should be
considered as "up-to-date".

I hope I have made myself understood.


2017-04-13 22:07 GMT+08:00 Jochen Theodorou <blackdrag@gmx.org>:

>
>
> On 13.04.2017 15:56, bo zhang wrote:
>
>> Hello everybody,
>>
>> I just have encountered a problem thus need your help. I want to treat
>> the following closures as "equivalent":
>>
>> Clousure c1={
>> "This is a closure"
>> }
>>
>> Clousure c2={
>> "This is a closure"
>> }
>>
>> assert closureEqual(c1,c2)
>>
>
> may I ask how you want to use that? I was thinking about this in the past,
> but I failed to create a reasonable scenario in which I would need this.
>
> Apparently, even though all fields and methods (the internal bytecode)
>> are equal, c1 and c2 are still different classes (xxx_closure$1 and
>> xxx_closure$2). AFAIK, everything but name in these two classes are equal.
>>
>> Is there any possibilities to achieve my goal? Thank you very much.
>>
>
> right now, not no.
>
> bye Jochen
>

Mime
View raw message