Commit 17c5bc9d authored by pengjunjing's avatar pengjunjing

增加匹配类型

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