nebula.core.GradleHelper.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nebula-core Show documentation
Show all versions of nebula-core Show documentation
Common classes that plugins might need
The newest version!
package nebula.core
import com.google.common.io.Files
import org.apache.commons.lang3.reflect.FieldUtils
import org.gradle.api.DomainObjectSet
import org.gradle.api.Project
import org.gradle.api.ProjectEvaluationListener
import org.gradle.api.artifacts.Configuration
import org.gradle.api.artifacts.Dependency
import org.gradle.api.internal.artifacts.configurations.DefaultConfiguration
import org.gradle.api.internal.artifacts.configurations.DetachedConfigurationsProvider
import org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolver
import org.gradle.api.internal.artifacts.ivyservice.resolutionstrategy.DefaultResolutionStrategy
import org.gradle.api.internal.project.AbstractProject
import org.gradle.internal.event.BroadcastDispatch
import org.gradle.listener.ClosureBackedMethodInvocationDispatch
import org.gradle.messaging.dispatch.Dispatch
import org.gradle.messaging.dispatch.MethodInvocation
/**
* Utility methods to dive into Gradle internals, if needed.
*/
class GradleHelper {
def AbstractProject project
GradleHelper(AbstractProject project) {
this.project = project
}
def static BroadcastDispatch getProjectEvaluationListeners(AbstractProject project) {
new GradleHelper(project).getProjectEvaluationListeners()
}
def BroadcastDispatch getProjectEvaluationListeners() {
ProjectEvaluationListener listener = project.getProjectEvaluationBroadcaster();
def /* org.gradle.messaging.dispatch.ProxyDispatchAdapter.DispatchingInvocationHandler */ h = ((java.lang.reflect.Proxy) listener).h
BroadcastDispatch dispatcher = h.dispatch
return dispatcher
}
def static beforeEvaluate(Project project, Closure beforeEvaluateClosure) {
new GradleHelper(project).beforeEvaluate(beforeEvaluateClosure)
}
def beforeEvaluate(Closure beforeEvaluateClosure) {
BroadcastDispatch broadcast = getProjectEvaluationListeners( (AbstractProject) project)
final String methodName = 'afterEvaluate'
Dispatch invocation = new ClosureBackedMethodInvocationDispatch(methodName, beforeEvaluateClosure)
Map