Last active
December 16, 2015 20:19
-
-
Save quidryan/5491942 to your computer and use it in GitHub Desktop.
Hack to get my afterEvaluation blocks to go before other ones.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
beforeAfterEvaluate { | |
println "Nah, nah, nah. I'm first" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def BroadcastDispatch<ProjectEvaluationListener> getProjectEvaluationListeners() { | |
ProjectEvaluationListener listener = ((AbstractProject) project).getProjectEvaluationBroadcaster(); | |
def /* org.gradle.messaging.dispatch.ProxyDispatchAdapter.DispatchingInvocationHandler */ h = ((java.lang.reflect.Proxy) listener).h | |
BroadcastDispatch<ProjectEvaluationListener> dispatcher = h.dispatch | |
return dispatcher | |
} | |
def beforeAfterEvaluate(Closure beforeEvaluateClosure) { | |
BroadcastDispatch<ProjectEvaluationListener> broadcast = getProjectEvaluationListeners() | |
final String methodName = 'afterEvaluate' | |
Dispatch<MethodInvocation> invocation = new ClosureBackedMethodInvocationDispatch(methodName, beforeEvaluateClosure) | |
Map<Object, Dispatch<MethodInvocation>> prependedHandlers = new LinkedHashMap<Object, Dispatch<MethodInvocation>>(); | |
prependedHandlers.put(invocation, invocation); | |
prependedHandlers.putAll( broadcast.handlers ) | |
broadcast.handlers.clear() | |
broadcast.handlers.putAll(prependedHandlers) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment