I can see that notify1 is marked as UP TO DATE, while notify2 is evaluated every time. If I run with -d, I cans ee this is because of the “matcher” is presumed different.
This is the expected behavior, as per the ‘equals’ contract of ‘groovy.lang.Closure’. To get the desired behavior, you’ll probably have to redesign the API (e.g. accept a ‘String’ or ‘Pattern’).
That’s what I am doing now, though in general I like being able to use GroovyObject.isCase() for specifying criteria.
May I suggest that Gradle adds special behavior for checking Input values in case of Pattern instances and instead of invoking the equals() on the instance itself, it compares against the return value of value.pattern() method?
This can be generalized to a registry of comparators per type, defaulting to equals() comparator.
It’s a possibility, though String seems to be a better fit here (build scripts shouldn’t have to be concerned with constructing ‘Pattern’ instances). Raised as GRADLE-2868.