Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
R
RemoveUnusedImg
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pengjunjing
RemoveUnusedImg
Commits
17c5bc9d
Commit
17c5bc9d
authored
Mar 22, 2023
by
pengjunjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加匹配类型
parent
887e84ff
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
6 deletions
+49
-6
build.gradle
build.gradle
+2
-0
MergeHelp.kts
...main/java/com/laihua/projecthelper/submerge/MergeHelp.kts
+44
-5
ParseUtil.kt
src/main/java/com/laihua/projecthelper/unuse/ParseUtil.kt
+3
-1
No files found.
build.gradle
View file @
17c5bc9d
...
...
@@ -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
src/main/java/com/laihua/projecthelper/submerge/MergeHelp.kts
View file @
17c5bc9d
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
()
}
}
}
src/main/java/com/laihua/projecthelper/unuse/ParseUtil.kt
View file @
17c5bc9d
...
...
@@ -17,11 +17,13 @@ class ParseUtil {
"R.mipmap"
,
"R.raw"
,
"R.layout"
,
"R.id"
,
"@layout"
,
"@color"
,
"R.anim"
,
"@anim"
,
"@xml"
"@xml"
,
"@navigation"
)
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment