码迷,mamicode.com
首页 > 其他好文 > 详细

Gradle源码一

时间:2014-12-19 15:49:59      阅读:171      评论:0      收藏:0      [点我收藏+]

标签: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源码一

标签:gradle

原文地址:http://blog.csdn.net/cleverwyq/article/details/42028231

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!