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

Gradle源码入门五

时间:2015-01-06 18:00:03      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:gradle   源码   

分析DefaultGradleLauncher.java

private void doBuildStages(Stage upTo) 函数的第二步

        // Evaluate settings script
        SettingsInternal settings = settingsHandler.findAndLoadSettings(gradle);
        buildListener.settingsEvaluated(settings);

从 startParameter 开始
StartParameter{taskRequests=[DefaultTaskExecutionRequest{args=[hello],projectPath='null'}], excludedTaskNames=[], currentDir=C:\Users\xxx\workspace\Gradle, searchUpwards=true, projectProperties={}, systemPropertiesArgs={}, gradleUserHomeDir=C:\Users\xxx\.gradle, gradleHome=C:\gradle-2.2.1, logLevel=LIFECYCLE, showStacktrace=INTERNAL_EXCEPTIONS, buildFile=null, initScripts=[], dryRun=false, rerunTasks=false, recompileScripts=false, offline=false, refreshDependencies=false, parallelThreadCount=0, configureOnDemand=false}

这个变量有一个searchUpwards, 如果为true,找
currentDir + settings.gradle
then loop:
	parentDir + settings.gradle
	parentDir/master + settings.gradle

找到一个有效的即止
------------------
如果为false,找到父目录即止
=========================
在org.gradle.initialization SettingsLocation.java

    public SettingsLocation(File settingsDir, File settingsFile) {
        this.settingsDir = settingsDir;
        this.settingsScriptSource = settingsFile == null
                ? new StringScriptSource("empty settings script", "")
                : new UriScriptSource("settings file", settingsFile);
    }

如果没有任何settings文件, settingdir就是currentDir, settingsFile is null

过程基本和init 文件相似,调用DefaultScriptPluginFactory.java 里面的 ScriptPluginImpl.apply 

结果

技术分享

Gradle源码入门五

标签:gradle   源码   

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

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