接上一遍Load过程的博客来继续 14. Gradle编译其他应用代码流程(三) - Load过程


这一边继续讲Configure过程。


Configure过程源代码

文件路径:

subprojects\core\src\main\java\org\gradle\initialization\DefaultGradleLauncher.java

privatevoiddoBuildStages(StageupTo){....if(stage==Stage.Load){//ConfigurebuildbuildOperationExecutor.run("Configurebuild",newRunnable(){@Overridepublicvoidrun(){buildConfigurer.configure(gradle);if(!gradle.getStartParameter().isConfigureOnDemand()){buildListener.projectsEvaluated(gradle);}modelConfigurationListener.onConfigure(gradle);}});stage=Stage.Configure;}...}


一. 首次看buildConfigurer.configure(gradle)


文件路径:

subprojects\core\src\main\java\org\gradle\configuration\DefaultBuildConfigurer.java

publicvoidconfigure(GradleInternalgradle){...projectConfigurer.configureHierarchy(gradle.getRootProject());}


文件路径:

subprojects\core\src\main\java\org\gradle\execution\TaskPathProjectEvaluator.java

publicclassTaskPathProjectEvaluatorimplementsProjectConfigurer{...publicvoidconfigureHierarchy(ProjectInternalproject){project.evaluate();for(Projectsub:project.getSubprojects()){if(cancellationToken.isCancellationRequested()){thrownewBuildCancelledException();}((ProjectInternal)sub).evaluate();}}}


在configureHierarchy里面,首先执行根项目的evaluate(),然后循环执行它的子项目的evaluate()。

就像往下面看:

文件路径:

subprojects\core\src\main\java\org\gradle\api\internal\project\DefaultProject.java

publicDefaultProjectevaluate(){getProjectEvaluator().evaluate(this,state);state.rethrowFailure();returnthis;}



subprojects\core\src\main\java\org\gradle\configuration\project\LifecycleProjectEvaluator.java

publicvoidevaluate(ProjectInternalproject,ProjectStateInternalstate){...state.setExecuting(true);try{delegate.evaluate(project,state);}catch(Exceptione){addConfigurationFailure(project,state,e);}finally{state.setExecuting(false);state.executed();notifyAfterEvaluate(listener,project,state);}}


subprojects\core\src\main\java\org\gradle\configuration\project\ConfigureActionsProjectEvaluator.java

publicclassConfigureActionsProjectEvaluatorimplementsProjectEvaluator{...publicvoidevaluate(ProjectInternalproject,ProjectStateInternalstate){for(ProjectConfigureActionconfigureAction:configureActions){configureAction.execute(project);}}}


subprojects\core\src\main\java\org\gradle\configuration\project\BuildScriptProcessor.java

publicclassBuildScriptProcessorimplementsProjectConfigureAction{...publicvoidexecute(ProjectInternalproject){...ScriptPluginconfigurer=configurerFactory.create(project.getBuildScriptSource(),project.getBuildscript(),project.getClassLoaderScope(),project.getBaseClassLoaderScope(),true);configurer.apply(project);...}}


接下来就会调用到ScriptPluginImpl.apply,这是我们上一遍讲过的。会去应用这个配置文件。具体怎么应用,需要看它生成的class文件。

文件路径在

D:\gradle_jar_cache\caches\3.1-snapshot-1\scripts-remapped\quality_cjfs2g3ij3bqjjsmf9bhahspf\2n69on6v0v04xd0c8c445muqy\dsld7eae713beda1bd9e69f8461da734880\classes


截个class内容的图:


这是因为我们的gradle文件配置了3个plugin

applyplugin:'checkstyle'applyplugin:'pmd'applyplugin:'findbugs'


所以,在configure阶段,它会去解析我们的配置文件,并且去加载我们配置的plugin插件。

以加载pmd插件为例,贴一个调用堆栈:

java.lang.Exception:SandyfindPluginDescriptorpluginId:org.gradle.pmdatorg.gradle.api.internal.plugins.ClassloaderBackedPluginDescriptorLocator.findPluginDescriptor(ClassloaderBackedPluginDescriptorLocator.java:31)atorg.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:59)atorg.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:51)atcom.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524)atcom.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317)atcom.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280)atcom.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195)atcom.google.common.cache.LocalCache.get(LocalCache.java:3934)atcom.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938)atcom.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821)atorg.gradle.api.internal.plugins.DefaultPluginRegistry.uncheckedGet(DefaultPluginRegistry.java:149)atorg.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:138)atorg.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:127)atorg.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:121)atorg.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:121)atorg.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:121)atorg.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:108)atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113)atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36)atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80)atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)atorg.gradle.groovy.scripts.DefaultScript.apply(DefaultScript.java:114)atorg.gradle.api.Script$apply$0.callCurrent(UnknownSource)atorg.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)atorg.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)atorg.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)atquality_cjfs2g3ij3bqjjsmf9bhahspf.run(E:\work_space\Android-Prototype\config\quality.gradle:2)atorg.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)atorg.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:176)atorg.gradle.configuration.DefaultScriptTarget.addConfiguration(DefaultScriptTarget.java:74)atorg.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:181)atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyScript(DefaultObjectConfigurationAction.java:102)atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$000(DefaultObjectConfigurationAction.java:36)atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction$1.run(DefaultObjectConfigurationAction.java:62)atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)atorg.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:44)atorg.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)atorg.gradle.api.Script$apply$0.callCurrent(UnknownSource)atorg.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)atorg.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)atorg.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)atbuild_840r8chxz90tc75jy1mlavsji.run(E:\work_space\Android-Prototype\app\build.gradle:3)atorg.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)atorg.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:176)atorg.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)atorg.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:181)atorg.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)atorg.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)atorg.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)atorg.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)atorg.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:573)atorg.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:125)atorg.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47)atorg.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)atorg.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:151)atorg.gradle.internal.Factories$1.create(Factories.java:22)atorg.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)atorg.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)atorg.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:148)atorg.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:33)atorg.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:112)atorg.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:106)atorg.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)atorg.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)atorg.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)atorg.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:92)atorg.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:67)atorg.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:31)atorg.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:43)atorg.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:42)atorg.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)atorg.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:79)atorg.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:51)atorg.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:54)atorg.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)atorg.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:250)atorg.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:217)atorg.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33)atorg.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)atorg.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)atorg.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)atorg.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:210)atorg.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:174)atorg.gradle.launcher.Main.doAction(Main.java:33)atorg.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)atjava.lang.reflect.Method.invoke(Method.java:483)atorg.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)atorg.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)atorg.gradle.launcher.GradleMain.main(GradleMain.java:24)


最后是在ClassloaderBackedPluginDescriptorLocator.findPluginDescriptor方法里面load plugin。


文件路径:

subprojects\core\src\main\java\org\gradle\api\internal\plugins\ClassloaderBackedPluginDescriptorLocator.java

publicclassClassloaderBackedPluginDescriptorLocatorimplementsPluginDescriptorLocator{...publicPluginDescriptorfindPluginDescriptor(StringpluginId){URLresource=classLoader.getResource("META-INF/gradle-plugins/"+pluginId+".properties");Exceptionex=newException("SandyfindPluginDescriptorpluginId:"+pluginId);ex.printStackTrace();if(resource==null){returnnull;}else{returnnewPluginDescriptor(resource);}}}


它会去找META-INF/gradle-plugins/'pluginid'.properties这个文件。

以pmd为例, pmd的这个配置文件路径是

subprojects\code-quality\src\main\resources\META-INF\gradle-plugins\org.gradle.pmd.properties



内容是implementation-class=org.gradle.api.plugins.quality.PmdPlugin 它表示pmd插件的描述类是PmdPlugin.java,需要去加载这个类。



二. 加载task

在Configure阶段会load所需要的task,以pmd为例,下面是调用堆栈:

10:10:14.934[ERROR][system.err]java.lang.Exception:Sandypmdinit10:10:14.934[ERROR][system.err]atorg.gradle.api.plugins.quality.Pmd.<init>(Pmd.java:68)10:10:14.934[ERROR][system.err]atorg.gradle.api.plugins.quality.Pmd_Decorated.<init>(UnknownSource)10:10:14.934[ERROR][system.err]atsun.reflect.NativeConstructorAccessorImpl.newInstance0(NativeMethod)10:10:14.934[ERROR][system.err]atsun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)10:10:14.934[ERROR][system.err]atsun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)10:10:14.934[ERROR][system.err]atjava.lang.reflect.Constructor.newInstance(Constructor.java:408)10:10:14.934[ERROR][system.err]atorg.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:56)10:10:14.934[ERROR][system.err]atorg.gradle.api.internal.ClassGeneratorBackedInstantiator.newInstance(ClassGeneratorBackedInstantiator.java:36)10:10:14.935[ERROR][system.err]atorg.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:121)10:10:14.935[ERROR][system.err]atorg.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:118)10:10:14.935[ERROR][system.err]atorg.gradle.util.GUtil.uncheckedCall(GUtil.java:401)10:10:14.935[ERROR][system.err]atorg.gradle.api.internal.AbstractTask.injectIntoNewInstance(AbstractTask.java:176)10:10:14.935[ERROR][system.err]atorg.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:118)10:10:14.935[ERROR][system.err]atorg.gradle.api.internal.project.taskfactory.TaskFactory.createTask(TaskFactory.java:77)10:10:14.935[ERROR][system.err]atorg.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.createTask(AnnotationProcessingTaskFactory.java:46)10:10:14.935[ERROR][system.err]atorg.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.createTask(DependencyAutoWireTaskFactory.java:39)10:10:14.935[ERROR][system.err]atorg.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:63)10:10:14.935[ERROR][system.err]atorg.gradle.api.internal.project.DefaultProject.task(DefaultProject.java:976)10:10:14.935[ERROR][system.err]atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)10:10:14.935[ERROR][system.err]atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)10:10:14.935[ERROR][system.err]atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)10:10:14.935[ERROR][system.err]atjava.lang.reflect.Method.invoke(Method.java:483)10:10:14.935[ERROR][system.err]atorg.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)10:10:14.935[ERROR][system.err]atgroovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)10:10:14.935[ERROR][system.err]atorg.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:382)10:10:14.935[ERROR][system.err]atorg.gradle.internal.metaobject.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:170)10:10:14.935[ERROR][system.err]atorg.gradle.internal.metaobject.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:96)10:10:14.935[ERROR][system.err]atorg.gradle.internal.metaobject.MixInClosurePropertiesAsMethodsDynamicObject.invokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:30)10:10:14.935[ERROR][system.err]atorg.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:163)10:10:14.935[ERROR][system.err]atorg.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:83)10:10:14.935[ERROR][system.err]atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)10:10:14.935[ERROR][system.err]atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)10:10:14.935[ERROR][system.err]atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)10:10:14.935[ERROR][system.err]atjava.lang.reflect.Method.invoke(Method.java:483)10:10:14.935[ERROR][system.err]atorg.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)10:10:14.935[ERROR][system.err]atgroovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:941)10:10:14.935[ERROR][system.err]atgroovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1264)10:10:14.935[ERROR][system.err]atgroovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1217)10:10:14.935[ERROR][system.err]atgroovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)10:10:14.935[ERROR][system.err]atorg.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69)10:10:14.935[ERROR][system.err]atorg.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)10:10:14.935[ERROR][system.err]atorg.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)10:10:14.935[ERROR][system.err]atorg.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182)10:10:14.935[ERROR][system.err]atquality_cjfs2g3ij3bqjjsmf9bhahspf.run(E:\work_space\Android-Prototype\config\quality.gradle:49)10:10:14.935[ERROR][system.err]atorg.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)10:10:14.936[ERROR][system.err]atorg.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:176)10:10:14.936[ERROR][system.err]atorg.gradle.configuration.DefaultScriptTarget.addConfiguration(DefaultScriptTarget.java:74)10:10:14.936[ERROR][system.err]atorg.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:181)10:10:14.936[ERROR][system.err]atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyScript(DefaultObjectConfigurationAction.java:102)10:10:14.936[ERROR][system.err]atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$000(DefaultObjectConfigurationAction.java:36)10:10:14.936[ERROR][system.err]atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction$1.run(DefaultObjectConfigurationAction.java:62)10:10:14.936[ERROR][system.err]atorg.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136)10:10:14.936[ERROR][system.err]atorg.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:44)10:10:14.936[ERROR][system.err]atorg.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34)10:10:14.936[ERROR][system.err]atorg.gradle.api.Script$apply$0.callCurrent(UnknownSource)10:10:14.936[ERROR][system.err]atorg.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52)10:10:14.936[ERROR][system.err]atorg.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154)10:10:14.936[ERROR][system.err]atorg.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166)10:10:14.936[ERROR][system.err]atbuild_840r8chxz90tc75jy1mlavsji.run(E:\work_space\Android-Prototype\app\build.gradle:3)10:10:14.936[ERROR][system.err]atorg.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90)10:10:14.936[ERROR][system.err]atorg.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:176)10:10:14.936[ERROR][system.err]atorg.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77)10:10:14.936[ERROR][system.err]atorg.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:181)10:10:14.936[ERROR][system.err]atorg.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38)10:10:14.936[ERROR][system.err]atorg.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25)10:10:14.936[ERROR][system.err]atorg.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)10:10:14.936[ERROR][system.err]atorg.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)10:10:14.936[ERROR][system.err]atorg.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:573)10:10:14.936[ERROR][system.err]atorg.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:125)10:10:14.936[ERROR][system.err]atorg.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47)10:10:14.936[ERROR][system.err]atorg.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38)10:10:14.936[ERROR][system.err]atorg.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:151)10:10:14.936[ERROR][system.err]atorg.gradle.internal.Factories$1.create(Factories.java:22)10:10:14.936[ERROR][system.err]atorg.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)10:10:14.936[ERROR][system.err]atorg.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53)10:10:14.936[ERROR][system.err]atorg.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:148)10:10:14.936[ERROR][system.err]atorg.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:33)10:10:14.936[ERROR][system.err]atorg.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:112)10:10:14.936[ERROR][system.err]atorg.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:106)10:10:14.936[ERROR][system.err]atorg.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)10:10:14.937[ERROR][system.err]atorg.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63)10:10:14.937[ERROR][system.err]atorg.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)10:10:14.937[ERROR][system.err]atorg.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:92)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:67)10:10:14.937[ERROR][system.err]atorg.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:31)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:43)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:42)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)10:10:14.937[ERROR][system.err]atorg.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:79)10:10:14.937[ERROR][system.err]atorg.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:51)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:54)10:10:14.937[ERROR][system.err]atorg.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:250)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:217)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:210)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:174)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.Main.doAction(Main.java:33)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)10:10:14.937[ERROR][system.err]atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)10:10:14.937[ERROR][system.err]atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)10:10:14.937[ERROR][system.err]atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)10:10:14.937[ERROR][system.err]atjava.lang.reflect.Method.invoke(Method.java:483)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37)10:10:14.937[ERROR][system.err]atorg.gradle.launcher.GradleMain.main(GradleMain.java:24)




三.buildListener.projectsEvaluated发送通知

文件路径:

subprojects\core\src\main\java\org\gradle\initialization\DefaultGradleLauncher.java

if(!gradle.getStartParameter().isConfigureOnDemand()){buildListener.projectsEvaluated(gradle);}

发送projectsEvaluated通知



四. 至此Configure阶段完成

这个阶段主要load了配置文件中的各种plugin;另外它的调用方法是通过加载生成的class文件来进行的。

D:\gradle_jar_cache\caches\3.1-snapshot-1\scripts-remapped\quality_cjfs2g3ij3bqjjsmf9bhahspf\2n69on6v0v04xd0c8c445muqy\dsld7eae713beda1bd9e69f8461da734880\classes

这样不同的配置文件可以用不同的类来执行加载动作,而代码保持一致。


接下来编译进入build阶段。

//Afterthispoint,theGradleLaunchercannotbereusedstage=Stage.Build;