Commit 86c96460 authored by pengjunjign's avatar pengjunjign

add:增加每日拉取一次代码的功能

parent c864aad8
......@@ -52,9 +52,41 @@ task importPushModule() {
}
//切换所有子仓库的分支,有网络操作,会增加编译耗时,项目第一次完整构建完后视情况自行注释
("git submodule foreach git checkout " + pushModuleCurrentBranch).execute()
//拉取最新代码,有网络操作,会增加编译耗时,项目第一次完整构建完后视情况自行注释
"git submodule foreach git pull".execute()
if (!isToday()) {
println("execute:git submodule foreach git pull")
//拉取最新代码,有网络操作,会增加编译耗时,项目第一次完整构建完后视情况自行注释
"git submodule foreach git pull".execute()
}
println("git submodule foreach git branch".execute().text)
println("add submodule after")
}
/**
* @return 今天是否更新过代码
*/
boolean isToday() {
def result = false
File file = new File(getProjectDir().toString()
+ File.separatorChar + "app"
+ File.separatorChar + "build"
+ File.separatorChar + "lastPullSubmoduleDate.txt"
)
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd")
def today = dateFormat.format(new Date())
if (file.exists()) {
def lines = file.readLines()
if (lines.size() > 0) {
result = (lines.get(0) == today)
}
}
//刷新日期内容
file.delete()
file.createNewFile()
BufferedWriter fileWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file, true), "UTF-8"));
fileWriter.write(today)
fileWriter.write("\n最后一次pull依赖仓库的时间,每日拉取一次")
fileWriter.flush()
fileWriter.close()
return result
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment