您好,登錄后才能下訂單哦!
接上一遍Load過程的博客來繼續 14. Gradle編譯其他應用代碼流程(三) - Load過程
這一邊繼續講Configure過程。
Configure過程源代碼
文件路徑:
subprojects\core\src\main\java\org\gradle\initialization\DefaultGradleLauncher.java
private void doBuildStages(Stage upTo) { .... if (stage == Stage.Load) { // Configure build buildOperationExecutor.run("Configure build", new Runnable() { @Override public void run() { 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
public void configure(GradleInternal gradle) { ... projectConfigurer.configureHierarchy(gradle.getRootProject()); }
文件路徑:
subprojects\core\src\main\java\org\gradle\execution\TaskPathProjectEvaluator.java
public class TaskPathProjectEvaluator implements ProjectConfigurer { ... public void configureHierarchy(ProjectInternal project) { project.evaluate(); for (Project sub : project.getSubprojects()) { if (cancellationToken.isCancellationRequested()) { throw new BuildCancelledException(); } ((ProjectInternal) sub).evaluate(); } } }
在configureHierarchy里面,首先執行根項目的evaluate(),然后循環執行它的子項目的evaluate()。
就像往下面看:
文件路徑:
subprojects\core\src\main\java\org\gradle\api\internal\project\DefaultProject.java
public DefaultProject evaluate() { getProjectEvaluator().evaluate(this, state); state.rethrowFailure(); return this; }
subprojects\core\src\main\java\org\gradle\configuration\project\LifecycleProjectEvaluator.java
public void evaluate(ProjectInternal project, ProjectStateInternal state) { ... state.setExecuting(true); try { delegate.evaluate(project, state); } catch (Exception e) { 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
public class ConfigureActionsProjectEvaluator implements ProjectEvaluator { ... public void evaluate(ProjectInternal project, ProjectStateInternal state) { for (ProjectConfigureAction configureAction : configureActions) { configureAction.execute(project); } } }
subprojects\core\src\main\java\org\gradle\configuration\project\BuildScriptProcessor.java
public class BuildScriptProcessor implements ProjectConfigureAction { ... public void execute(ProjectInternal project) { ... ScriptPlugin configurer = 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
apply plugin: 'checkstyle' apply plugin: 'pmd' apply plugin: 'findbugs'
所以,在configure階段,它會去解析我們的配置文件,并且去加載我們配置的plugin插件。
以加載pmd插件為例,貼一個調用堆棧:
java.lang.Exception: Sandy findPluginDescriptor pluginId: org.gradle.pmd at org.gradle.api.internal.plugins.ClassloaderBackedPluginDescriptorLocator.findPluginDescriptor(ClassloaderBackedPluginDescriptorLocator.java:31) at org.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:59) at org.gradle.api.internal.plugins.DefaultPluginRegistry$1.load(DefaultPluginRegistry.java:51) at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) at com.google.common.cache.LocalCache.get(LocalCache.java:3934) at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) at org.gradle.api.internal.plugins.DefaultPluginRegistry.uncheckedGet(DefaultPluginRegistry.java:149) at org.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:138) at org.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:127) at org.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:121) at org.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:121) at org.gradle.api.internal.plugins.DefaultPluginRegistry.lookup(DefaultPluginRegistry.java:121) at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:108) at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyType(DefaultObjectConfigurationAction.java:113) at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:36) at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:80) at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136) at org.gradle.groovy.scripts.DefaultScript.apply(DefaultScript.java:114) at org.gradle.api.Script$apply$0.callCurrent(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) at quality_cjfs2g3ij3bqjjsmf9bhahspf.run(E:\work_space\Android-Prototype\config\quality.gradle:2) at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90) at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:176) at org.gradle.configuration.DefaultScriptTarget.addConfiguration(DefaultScriptTarget.java:74) at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:181) at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyScript(DefaultObjectConfigurationAction.java:102) at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$000(DefaultObjectConfigurationAction.java:36) at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$1.run(DefaultObjectConfigurationAction.java:62) at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136) at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:44) at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34) at org.gradle.api.Script$apply$0.callCurrent(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) at build_840r8chxz90tc75jy1mlavsji.run(E:\work_space\Android-Prototype\app\build.gradle:3) at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90) at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:176) at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77) at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:181) at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38) at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25) at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34) at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55) at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:573) at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:125) at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47) at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38) at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:151) at org.gradle.internal.Factories$1.create(Factories.java:22) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:148) at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:33) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:112) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:106) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:92) at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:67) at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:31) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:43) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:42) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26) at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:79) at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:51) at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:54) at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:250) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:217) at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33) at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:210) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:174) at org.gradle.launcher.Main.doAction(Main.java:33) at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60) at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37) at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
最后是在ClassloaderBackedPluginDescriptorLocator.findPluginDescriptor方法里面load plugin。
文件路徑:
subprojects\core\src\main\java\org\gradle\api\internal\plugins\ClassloaderBackedPluginDescriptorLocator.java
public class ClassloaderBackedPluginDescriptorLocator implements PluginDescriptorLocator { ... public PluginDescriptor findPluginDescriptor(String pluginId) { URL resource = classLoader.getResource("META-INF/gradle-plugins/" + pluginId + ".properties"); Exception ex = new Exception("Sandy findPluginDescriptor pluginId: " + pluginId); ex.printStackTrace(); if (resource == null) { return null; } else { return new PluginDescriptor(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: Sandy pmd init 10:10:14.934 [ERROR] [system.err] at org.gradle.api.plugins.quality.Pmd.<init>(Pmd.java:68) 10:10:14.934 [ERROR] [system.err] at org.gradle.api.plugins.quality.Pmd_Decorated.<init>(Unknown Source) 10:10:14.934 [ERROR] [system.err] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 10:10:14.934 [ERROR] [system.err] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 10:10:14.934 [ERROR] [system.err] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 10:10:14.934 [ERROR] [system.err] at java.lang.reflect.Constructor.newInstance(Constructor.java:408) 10:10:14.934 [ERROR] [system.err] at org.gradle.api.internal.DependencyInjectingInstantiator.newInstance(DependencyInjectingInstantiator.java:56) 10:10:14.934 [ERROR] [system.err] at org.gradle.api.internal.ClassGeneratorBackedInstantiator.newInstance(ClassGeneratorBackedInstantiator.java:36) 10:10:14.935 [ERROR] [system.err] at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:121) 10:10:14.935 [ERROR] [system.err] at org.gradle.api.internal.project.taskfactory.TaskFactory$1.call(TaskFactory.java:118) 10:10:14.935 [ERROR] [system.err] at org.gradle.util.GUtil.uncheckedCall(GUtil.java:401) 10:10:14.935 [ERROR] [system.err] at org.gradle.api.internal.AbstractTask.injectIntoNewInstance(AbstractTask.java:176) 10:10:14.935 [ERROR] [system.err] at org.gradle.api.internal.project.taskfactory.TaskFactory.create(TaskFactory.java:118) 10:10:14.935 [ERROR] [system.err] at org.gradle.api.internal.project.taskfactory.TaskFactory.createTask(TaskFactory.java:77) 10:10:14.935 [ERROR] [system.err] at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory.createTask(AnnotationProcessingTaskFactory.java:46) 10:10:14.935 [ERROR] [system.err] at org.gradle.api.internal.project.taskfactory.DependencyAutoWireTaskFactory.createTask(DependencyAutoWireTaskFactory.java:39) 10:10:14.935 [ERROR] [system.err] at org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:63) 10:10:14.935 [ERROR] [system.err] at org.gradle.api.internal.project.DefaultProject.task(DefaultProject.java:976) 10:10:14.935 [ERROR] [system.err] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 10:10:14.935 [ERROR] [system.err] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 10:10:14.935 [ERROR] [system.err] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 10:10:14.935 [ERROR] [system.err] at java.lang.reflect.Method.invoke(Method.java:483) 10:10:14.935 [ERROR] [system.err] at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) 10:10:14.935 [ERROR] [system.err] at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325) 10:10:14.935 [ERROR] [system.err] at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:382) 10:10:14.935 [ERROR] [system.err] at org.gradle.internal.metaobject.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:170) 10:10:14.935 [ERROR] [system.err] at org.gradle.internal.metaobject.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:96) 10:10:14.935 [ERROR] [system.err] at org.gradle.internal.metaobject.MixInClosurePropertiesAsMethodsDynamicObject.invokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:30) 10:10:14.935 [ERROR] [system.err] at org.gradle.internal.metaobject.AbstractDynamicObject.invokeMethod(AbstractDynamicObject.java:163) 10:10:14.935 [ERROR] [system.err] at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:83) 10:10:14.935 [ERROR] [system.err] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 10:10:14.935 [ERROR] [system.err] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 10:10:14.935 [ERROR] [system.err] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 10:10:14.935 [ERROR] [system.err] at java.lang.reflect.Method.invoke(Method.java:483) 10:10:14.935 [ERROR] [system.err] at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93) 10:10:14.935 [ERROR] [system.err] at groovy.lang.MetaClassImpl.invokeMissingMethod(MetaClassImpl.java:941) 10:10:14.935 [ERROR] [system.err] at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1264) 10:10:14.935 [ERROR] [system.err] at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1217) 10:10:14.935 [ERROR] [system.err] at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024) 10:10:14.935 [ERROR] [system.err] at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:69) 10:10:14.935 [ERROR] [system.err] at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) 10:10:14.935 [ERROR] [system.err] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) 10:10:14.935 [ERROR] [system.err] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:182) 10:10:14.935 [ERROR] [system.err] at quality_cjfs2g3ij3bqjjsmf9bhahspf.run(E:\work_space\Android-Prototype\config\quality.gradle:49) 10:10:14.935 [ERROR] [system.err] at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90) 10:10:14.936 [ERROR] [system.err] at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:176) 10:10:14.936 [ERROR] [system.err] at org.gradle.configuration.DefaultScriptTarget.addConfiguration(DefaultScriptTarget.java:74) 10:10:14.936 [ERROR] [system.err] at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:181) 10:10:14.936 [ERROR] [system.err] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyScript(DefaultObjectConfigurationAction.java:102) 10:10:14.936 [ERROR] [system.err] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$000(DefaultObjectConfigurationAction.java:36) 10:10:14.936 [ERROR] [system.err] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$1.run(DefaultObjectConfigurationAction.java:62) 10:10:14.936 [ERROR] [system.err] at org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:136) 10:10:14.936 [ERROR] [system.err] at org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:44) 10:10:14.936 [ERROR] [system.err] at org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.java:34) 10:10:14.936 [ERROR] [system.err] at org.gradle.api.Script$apply$0.callCurrent(Unknown Source) 10:10:14.936 [ERROR] [system.err] at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:52) 10:10:14.936 [ERROR] [system.err] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:154) 10:10:14.936 [ERROR] [system.err] at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:166) 10:10:14.936 [ERROR] [system.err] at build_840r8chxz90tc75jy1mlavsji.run(E:\work_space\Android-Prototype\app\build.gradle:3) 10:10:14.936 [ERROR] [system.err] at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:90) 10:10:14.936 [ERROR] [system.err] at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl$2.run(DefaultScriptPluginFactory.java:176) 10:10:14.936 [ERROR] [system.err] at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:77) 10:10:14.936 [ERROR] [system.err] at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:181) 10:10:14.936 [ERROR] [system.err] at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:38) 10:10:14.936 [ERROR] [system.err] at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:25) 10:10:14.936 [ERROR] [system.err] at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34) 10:10:14.936 [ERROR] [system.err] at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55) 10:10:14.936 [ERROR] [system.err] at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:573) 10:10:14.936 [ERROR] [system.err] at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:125) 10:10:14.936 [ERROR] [system.err] at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:47) 10:10:14.936 [ERROR] [system.err] at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:38) 10:10:14.936 [ERROR] [system.err] at org.gradle.initialization.DefaultGradleLauncher$2.run(DefaultGradleLauncher.java:151) 10:10:14.936 [ERROR] [system.err] at org.gradle.internal.Factories$1.create(Factories.java:22) 10:10:14.936 [ERROR] [system.err] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) 10:10:14.936 [ERROR] [system.err] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:53) 10:10:14.936 [ERROR] [system.err] at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:148) 10:10:14.936 [ERROR] [system.err] at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:33) 10:10:14.936 [ERROR] [system.err] at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:112) 10:10:14.936 [ERROR] [system.err] at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:106) 10:10:14.936 [ERROR] [system.err] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91) 10:10:14.937 [ERROR] [system.err] at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:63) 10:10:14.937 [ERROR] [system.err] at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106) 10:10:14.937 [ERROR] [system.err] at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:92) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:67) 10:10:14.937 [ERROR] [system.err] at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:31) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:43) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:42) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26) 10:10:14.937 [ERROR] [system.err] at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:79) 10:10:14.937 [ERROR] [system.err] at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:51) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:54) 10:10:14.937 [ERROR] [system.err] at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:173) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:250) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:217) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:33) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:210) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:174) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.Main.doAction(Main.java:33) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) 10:10:14.937 [ERROR] [system.err] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 10:10:14.937 [ERROR] [system.err] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 10:10:14.937 [ERROR] [system.err] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 10:10:14.937 [ERROR] [system.err] at java.lang.reflect.Method.invoke(Method.java:483) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:60) 10:10:14.937 [ERROR] [system.err] at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:37) 10:10:14.937 [ERROR] [system.err] at org.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階段。
// After this point, the GradleLauncher cannot be reused stage = Stage.Build;
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。