Commit 17c5bc9d authored by pengjunjing's avatar pengjunjing

增加匹配类型

parent 887e84ff
......@@ -10,4 +10,6 @@ java {
dependencies{
implementation "org.jdom:jdom:2.0.2"
implementation "org.jetbrains.kotlin:kotlin-script-runtime:1.8.0"
// implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.0"
}
\ No newline at end of file
package com.laihua.projecthelper.submerge
import java.io.File
import java.lang.StringBuilder
/**
*合并助手,用于动画模块开子模块分支的时候,跟开发模块合并的工具类
* 目前合并完成应该不再使用了
*/
main()
fun main() {
......@@ -28,6 +34,12 @@ fun main() {
for (file in allFilesIncludeSub) {
println("--> ${file.path}")
}
it.walk().forEach { oneDir ->
if (oneDir.isDirectory && oneDir.listFiles()?.size == 0) {
println("空文件夹:${oneDir.path}")
oneDir.deleteEmptyDir()
}
}
}
val sumOf = mKtModelOldDirs?.sumOf {
it.getAllFilesIncludeSub().size
......@@ -37,6 +49,9 @@ fun main() {
val moveInfoList = mutableListOf<MoveInfo>()
outModuleFiles.forEach { oldFile ->
if (oldFile.path.endsWith("gradle")) {
return@forEach
}
var tmpPath = oldFile.path.replace(targetPath, "")
if (tmpPath.startsWith(File.separator)) {
tmpPath = tmpPath.replaceFirst(File.separator, "")
......@@ -53,12 +68,13 @@ fun main() {
var replace = oldFile.path.replace(targetPath, "")
replace = replace.replaceFirst("${File.separator}$moduleName", "")
replace = newParentFileTarget.path + replace
if (File(replace).exists()) {
// println("新位置,存在相同文件 ${oldFile.path} -> $replace")
println("新位置,存在相同文件 ${oldFile.path} -> $replace")
moveInfoList.add(MoveInfo(moduleName, oldFile, File(replace)))
} else {
println("新位置,需要新增的文件 ${oldFile.path} -> $replace")
// println("新位置,需要新增的文件 ${oldFile.path} -> $replace")
}
}
......@@ -66,15 +82,30 @@ fun main() {
}
println("需要移动的总数:${moveInfoList.size}")
moveInfoList.forEach {
val logFile = File("E:\\海外合并备份\\移动记录.txt")
val sb = StringBuilder()
moveInfoList.forEach {
val s = "${it.moduleName} ${it.new.name}\n${it.old.path}\n${it.new.path}"
sb.append(s).append("\n\n")
// it.oldCoverNew()
}
sb.append("总数:${moveInfoList.size}")
logFile.delete()
logFile.createNewFile()
logFile.writeText(sb.toString())
}
class MoveInfo(val moduleName: String, old: File, new: File) {
class MoveInfo(val moduleName: String, val old: File, val new: File) {
/**
* 旧文件覆盖新文件
*/
fun oldCoverNew() {
new.delete()
old.renameTo(new)
}
}
/**
......@@ -98,3 +129,11 @@ fun File.getAllFilesIncludeSub(): List<File> {
return files
}
fun File.deleteEmptyDir() {
if (this.isDirectory) {
if (this.listFiles()?.size == 0) {
this.delete()
this.parentFile.deleteEmptyDir()
}
}
}
......@@ -17,11 +17,13 @@ class ParseUtil {
"R.mipmap",
"R.raw",
"R.layout",
"R.id",
"@layout",
"@color",
"R.anim",
"@anim",
"@xml"
"@xml",
"@navigation"
)
/**
......
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