Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 19859

Exclude dependency using Java instead of Groovy (aka closures in Java)

$
0
0

Thanks. I ended up with the second option, which works just great.

Regarding the first option, I had to add non-null owner in the ActionClosure constructor:

import gradle.api.Action;
import groovy.lang.Closure;
public class ActionClosure<T> extends Closure<Object> {
    private final Action<T> action;
    public ActionClosure(Object owner, Action<T> action) {
        super(owner);
        this.action = action;
    } 
    @Override
    public Object call() {
        action.execute((T) getDelegate());
        return null;
    } 
} 

and I passed project as owner (though I think it could have been anything). Otherwise I got IllegalArgumentException saying “Value is null”.


Viewing all articles
Browse latest Browse all 19859

Trending Articles