It’s difficult to figure out how a Gradle script works as a pure Groovy script. Such as, where are the “buildscript/task/project/allprojects/subprojects/dependencies” functions defined, if they are function calls really?
From here I know: by default the following classes are imported into a Gradle build script:
# Run the "build.gradle" script: ~/temp> gradle -q introspect task class: class org.gradle.api.DefaultTask_Decorated class java.lang.String <org.gradle.api.DefaultTask_Decorated@63259e68 __meta_class__=groovy.lang.MetaClassImpl@68c159ff[class org.gradle.api.DefaultTask_Decorated] project=root project 'temp' name=introspect actions=[] path=:introspect enabled=true dependencies=org.gradle.api.internal.tasks.DefaultTaskDependency@6143523b mustRunAfter=org.gradle.api.internal.tasks.DefaultTaskDependency@6842d1a3 finalizedBy=org.gradle.api.internal.tasks.DefaultTaskDependency@275bd41d shouldRunAfter=org.gradle.api.internal.tasks.DefaultTaskDependency@605d6181 extensibleDynamicObject=DynamicObject for task ':introspect' description=null group=null onlyIfSpec=org.gradle.api.specs.AndSpec@c3ad0576 executer=null services=ProjectScopeServices state=org.gradle.api.internal.tasks.TaskStateInternal@6545302f validators=[] taskMutator=org.gradle.api.internal.tasks.TaskMutator@1cc7eba6 observableActionList=[] impliesSubProjects=false hasCustomActions=false toStringValue=task ':introspect' identityPath=:introspect taskInputs=org.gradle.api.internal.tasks.DefaultTaskInputs@179dc0d6 taskOutputs=org.gradle.api.internal.tasks.DefaultTaskOutputs@2d7af2e3 publicType=class org.gradle.api.DefaultTask loggingManager=null> public boolean java.lang.Object.equals(java.lang.Object) public final native java.lang.Class java.lang.Object.getClass() public native int java.lang.Object.hashCode() public final native void java.lang.Object.notify() public final native void java.lang.Object.notifyAll() public java.lang.String java.lang.Object.toString() public final void java.lang.Object.wait() throws java.lang.InterruptedException public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException public void org.gradle.api.internal.AbstractTask.addValidator(org.gradle.api.internal.tasks.execution.TaskValidator) public void org.gradle.api.internal.AbstractTask.appendParallelSafeAction(org.gradle.api.Action) public int org.gradle.api.internal.AbstractTask.compareTo(org.gradle.api.Task) public org.gradle.api.Task org.gradle.api.internal.AbstractTask.configure(groovy.lang.Closure) public org.gradle.api.Task org.gradle.api.internal.AbstractTask.deleteAllActions() public org.gradle.api.Task org.gradle.api.internal.AbstractTask.dependsOn(java.lang.Object[]) public boolean org.gradle.api.internal.AbstractTask.dependsOnTaskDidWork() public org.gradle.api.Task org.gradle.api.internal.AbstractTask.doFirst(groovy.lang.Closure) public org.gradle.api.Task org.gradle.api.internal.AbstractTask.doFirst(org.gradle.api.Action) public org.gradle.api.Task org.gradle.api.internal.AbstractTask.doLast(groovy.lang.Closure) public org.gradle.api.Task org.gradle.api.internal.AbstractTask.doLast(org.gradle.api.Action) public final void org.gradle.api.internal.AbstractTask.execute() public org.gradle.api.Task org.gradle.api.internal.AbstractTask.finalizedBy(java.lang.Object[]) public java.util.Set org.gradle.api.internal.AbstractTask.getActionClassLoaders() public java.util.List org.gradle.api.internal.AbstractTask.getActions() public org.gradle.api.AntBuilder org.gradle.api.internal.AbstractTask.getAnt() public org.gradle.internal.metaobject.DynamicObject org.gradle.api.internal.AbstractTask.getAsDynamicObject() public org.gradle.api.plugins.Convention org.gradle.api.internal.AbstractTask.getConvention() public java.util.Set org.gradle.api.internal.AbstractTask.getDependsOn() public java.lang.String org.gradle.api.internal.AbstractTask.getDescription() public boolean org.gradle.api.internal.AbstractTask.getDidWork() public boolean org.gradle.api.internal.AbstractTask.getEnabled() public org.gradle.api.internal.tasks.TaskExecuter org.gradle.api.internal.AbstractTask.getExecuter() public org.gradle.api.plugins.ExtensionContainer org.gradle.api.internal.AbstractTask.getExtensions() public org.gradle.api.tasks.TaskDependency org.gradle.api.internal.AbstractTask.getFinalizedBy() public java.lang.String org.gradle.api.internal.AbstractTask.getGroup() public org.gradle.util.Path org.gradle.api.internal.AbstractTask.getIdentityPath() public boolean org.gradle.api.internal.AbstractTask.getImpliesSubProjects() public org.gradle.api.internal.TaskInputsInternal org.gradle.api.internal.AbstractTask.getInputs() public org.gradle.api.logging.Logger org.gradle.api.internal.AbstractTask.getLogger() public org.gradle.logging.LoggingManagerInternal org.gradle.api.internal.AbstractTask.getLogging() public org.gradle.api.tasks.TaskDependency org.gradle.api.internal.AbstractTask.getMustRunAfter() public java.lang.String org.gradle.api.internal.AbstractTask.getName() public org.gradle.api.specs.Spec org.gradle.api.internal.AbstractTask.getOnlyIf() public org.gradle.api.internal.TaskOutputsInternal org.gradle.api.internal.AbstractTask.getOutputs() public java.lang.String org.gradle.api.internal.AbstractTask.getPath() public org.gradle.api.Project org.gradle.api.internal.AbstractTask.getProject() public org.gradle.api.tasks.TaskDependency org.gradle.api.internal.AbstractTask.getShouldRunAfter() public org.gradle.logging.StandardOutputCapture org.gradle.api.internal.AbstractTask.getStandardOutputCapture() public org.gradle.api.internal.tasks.TaskStateInternal org.gradle.api.internal.AbstractTask.getState() public java.util.List org.gradle.api.internal.AbstractTask.getTaskActions() public org.gradle.api.internal.tasks.TaskDependencyInternal org.gradle.api.internal.AbstractTask.getTaskDependencies() public java.io.File org.gradle.api.internal.AbstractTask.getTemporaryDir() public org.gradle.internal.Factory org.gradle.api.internal.AbstractTask.getTemporaryDirFactory() public java.util.List org.gradle.api.internal.AbstractTask.getValidators() public boolean org.gradle.api.internal.AbstractTask.hasProperty(java.lang.String) public static org.gradle.api.Task org.gradle.api.internal.AbstractTask.injectIntoNewInstance(org.gradle.api.internal.project.ProjectInternal,java.lang.String,java.lang.Class,java.util.concurrent.Callable) public boolean org.gradle.api.internal.AbstractTask.isEnabled() public boolean org.gradle.api.internal.AbstractTask.isHasCustomActions() public org.gradle.api.Task org.gradle.api.internal.AbstractTask.leftShift(groovy.lang.Closure) public org.gradle.api.Task org.gradle.api.internal.AbstractTask.mustRunAfter(java.lang.Object[]) public void org.gradle.api.internal.AbstractTask.onlyIf(groovy.lang.Closure) public void org.gradle.api.internal.AbstractTask.onlyIf(org.gradle.api.specs.Spec) public void org.gradle.api.internal.AbstractTask.prependParallelSafeAction(org.gradle.api.Action) public java.lang.Object org.gradle.api.internal.AbstractTask.property(java.lang.String) throws groovy.lang.MissingPropertyException public void org.gradle.api.internal.AbstractTask.setActions(java.util.List) public void org.gradle.api.internal.AbstractTask.setDependsOn(java.lang.Iterable) public void org.gradle.api.internal.AbstractTask.setDescription(java.lang.String) public void org.gradle.api.internal.AbstractTask.setDidWork(boolean) public void org.gradle.api.internal.AbstractTask.setEnabled(boolean) public void org.gradle.api.internal.AbstractTask.setExecuter(org.gradle.api.internal.tasks.TaskExecuter) public void org.gradle.api.internal.AbstractTask.setFinalizedBy(java.lang.Iterable) public void org.gradle.api.internal.AbstractTask.setGroup(java.lang.String) public void org.gradle.api.internal.AbstractTask.setImpliesSubProjects(boolean) public void org.gradle.api.internal.AbstractTask.setMustRunAfter(java.lang.Iterable) public void org.gradle.api.internal.AbstractTask.setOnlyIf(groovy.lang.Closure) public void org.gradle.api.internal.AbstractTask.setOnlyIf(org.gradle.api.specs.Spec) public void org.gradle.api.internal.AbstractTask.setProperty(java.lang.String,java.lang.Object) public void org.gradle.api.internal.AbstractTask.setShouldRunAfter(java.lang.Iterable) public org.gradle.api.tasks.TaskDependency org.gradle.api.internal.AbstractTask.shouldRunAfter(java.lang.Object[]) public java.lang.String org.gradle.api.internal.AbstractTask.toString() public void org.gradle.api.DefaultTask_Decorated.appendParallelSafeAction(groovy.lang.Closure) public void org.gradle.api.DefaultTask_Decorated.description(java.lang.String) public void org.gradle.api.DefaultTask_Decorated.didWork(boolean) public void org.gradle.api.DefaultTask_Decorated.enabled(boolean) public void org.gradle.api.DefaultTask_Decorated.executer(org.gradle.api.internal.tasks.TaskExecuter) public groovy.lang.MetaClass org.gradle.api.DefaultTask_Decorated.getMetaClass() public java.lang.Object org.gradle.api.DefaultTask_Decorated.getProperty(java.lang.String) public void org.gradle.api.DefaultTask_Decorated.group(java.lang.String) public boolean org.gradle.api.DefaultTask_Decorated.hasProperty(java.lang.String) public void org.gradle.api.DefaultTask_Decorated.impliesSubProjects(boolean) public java.lang.Object org.gradle.api.DefaultTask_Decorated.invokeMethod(java.lang.String,java.lang.Object) public void org.gradle.api.DefaultTask_Decorated.prependParallelSafeAction(groovy.lang.Closure) public void org.gradle.api.DefaultTask_Decorated.setMetaClass(groovy.lang.MetaClass) public void org.gradle.api.DefaultTask_Decorated.setProperty(java.lang.String,java.lang.Object