Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,18 @@ public class ReClassTransform extends Transform {
includeJars.each {
File jar = new File(it)
String JarAfterzip = map.get(jar.getParent() + File.separatorChar + jar.getName())
String dirAfterUnzip = JarAfterzip.replace('.jar', '')
// println ">>> 压缩目录 $dirAfterUnzip"

Util.zipDir(dirAfterUnzip, JarAfterzip)
if(JarAfterzip != null){
String dirAfterUnzip = JarAfterzip.replace('.jar', '')
File dirAfterUnzipFile = new File(dirAfterUnzip);
if(dirAfterUnzipFile.exists()){
// println ">>> 压缩目录 $dirAfterUnzip"

// println ">>> 删除目录 $dirAfterUnzip"
FileUtils.deleteDirectory(new File(dirAfterUnzip))
Util.zipDir(dirAfterUnzip, JarAfterzip)

// println ">>> 删除目录 $dirAfterUnzip"
FileUtils.deleteDirectory(dirAfterUnzipFile)
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,23 @@ public class Util {
boolean needInject = checkNeedInjector(infoMap, jar, reJar, activityMd5, md5);

//设置重定向jar
setJarInput(jarInput, reJar)
// setJarInput(jarInput, reJar)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

无用的import和方法,变量声明等,请移除

//ReClassTransform.copyJar需要用到
map.put(jar.getAbsolutePath(), jarPath)
if (needInject) {
/* 将 jar 包解压,并将解压后的目录加入 classpath */
// println ">>> 解压Jar${jarPath}"
String jarZipDir = reJar.getParent() + File.separatorChar + reJar.getName().replace('.jar', '')
if (unzip(jar.getAbsolutePath(), jarZipDir)) {

includeJars << jarPath
includeJars << jar.getAbsolutePath()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

保持原代码不变,jarPath已经获取了全路径。相关代码需要调整下

classPath << jarZipDir
//保存修改的插件版本号
needSave = true
infoMap.put(jar.getAbsolutePath(), new JarPatchInfo(jar, activityMd5))

visitor.setBaseDir(jarZipDir)
Files.walkFileTree(Paths.get(jarZipDir), visitor)

map.put(jarPath, jarPath)
}
// 删除 jar
if (reJar.exists()) {
Expand Down