首页 > 代码库 > Gradle源码一
Gradle源码一
Gradle执行的关键代码 org.gradle.initialization.DefaultGradleLauncher.java
private void doBuildStages(Stage upTo) { // Evaluate init scripts initScriptHandler.executeScripts(gradle); // Evaluate settings script SettingsInternal settings = settingsHandler.findAndLoadSettings(gradle); buildListener.settingsEvaluated(settings); // Load build buildLoader.load(settings.getRootProject(), settings.getDefaultProject(), gradle, settings.getRootClassLoaderScope()); buildListener.projectsLoaded(gradle); // Configure build buildConfigurer.configure(gradle); if (!gradle.getStartParameter().isConfigureOnDemand()) { buildListener.projectsEvaluated(gradle); } modelConfigurationListener.onConfigure(gradle); if (upTo == Stage.Configure) { return; } // Populate task graph buildExecuter.select(gradle); if (gradle.getStartParameter().isConfigureOnDemand()) { buildListener.projectsEvaluated(gradle); } // Execute build buildExecuter.execute(); tasksCompletionListener.onTasksFinished(gradle); assert upTo == Stage.Build; }
从注释上我们可以看出gradle的几个关键步骤
A. Evaluate init scripts
1.InitScriptHandler 通过
protected InitScriptHandler createInitScriptHandler() { return new InitScriptHandler( new DefaultInitScriptProcessor( get(ScriptPluginFactory.class), get(ScriptHandlerFactory.class) ) ); }指定了
DefaultInitScriptProcessor <span style="font-family: Arial, Helvetica, sans-serif;">对象做它的 processor</span>
2.指定Script finder (in org.gradle.startParameter.java)
从 C:\Users\xxx\.gradle\init.gradle <-USER_HOME
C:\Users\xxx\.gradle\init.d 文件夹中endswith ".gradle" <- USER_HOME
C:\gradle-2.2.1\init.d 文件夹中 endswith ".gradle" <- GRADLE_HOME
3.调用DefaultInitScriptProcessor.processs 函数处理
Gradle源码一
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。