diff --git a/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/AndroidAopPlugin.kt b/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/AndroidAopPlugin.kt index be4eb6a4..c63cf661 100644 --- a/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/AndroidAopPlugin.kt +++ b/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/AndroidAopPlugin.kt @@ -113,7 +113,9 @@ class AndroidAopPlugin : Plugin { } if (localInput.isNotEmpty()){ val output = File(javaCompile.destinationDirectory.asFile.orNull.toString()) - val task = CompileAndroidAopTask(jarInput,localInput,output,project,isApp) + val task = CompileAndroidAopTask(jarInput,localInput,output,project,isApp, + File(project.buildDir.path + "/tmp/android-aop/" + fullName) + ) task.taskAction() } } diff --git a/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/CompileAndroidAopTask.kt b/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/CompileAndroidAopTask.kt index 3982782d..e398b9ba 100644 --- a/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/CompileAndroidAopTask.kt +++ b/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/CompileAndroidAopTask.kt @@ -3,6 +3,7 @@ package com.flyjingfish.android_aop_plugin import com.flyjingfish.android_aop_plugin.beans.ClassMethodRecord import com.flyjingfish.android_aop_plugin.beans.MethodRecord import com.flyjingfish.android_aop_plugin.beans.ReplaceMethodInfo +import com.flyjingfish.android_aop_plugin.beans.TmpFile import com.flyjingfish.android_aop_plugin.config.AndroidAopConfig import com.flyjingfish.android_aop_plugin.scanner_visitor.SearchAopMethodVisitor import com.flyjingfish.android_aop_plugin.scanner_visitor.SearchAOPConfigVisitor @@ -45,7 +46,8 @@ class CompileAndroidAopTask(val allJars: MutableList, val allDirectories: MutableList, val output: File, val project: Project, - val outPutInitClass:Boolean + val outPutInitClass:Boolean, + val tmpFile:File ) { @@ -326,7 +328,6 @@ class CompileAndroidAopTask(val allJars: MutableList, WovenInfoUtils.removeDeletedClassMethodRecord() WovenInfoUtils.verifyModifyExtendsClassInfo() } - private fun wovenIntoCode(){ val includes = AndroidAopConfig.includes val excludes = AndroidAopConfig.excludes @@ -334,7 +335,7 @@ class CompileAndroidAopTask(val allJars: MutableList, // logger.error("getClassMethodRecord="+WovenInfoUtils.classMethodRecords) val hasReplace = WovenInfoUtils.hasReplace() val hasReplaceExtendsClass = WovenInfoUtils.hasModifyExtendsClass() - + val tempFiles = mutableListOf() fun processFile(file : File,directory:File,directoryPath:String){ if (file.isFile) { val entryName = file.absolutePath.replace("$directoryPath/","") @@ -343,7 +344,15 @@ class CompileAndroidAopTask(val allJars: MutableList, } val relativePath = directory.toURI().relativize(file.toURI()).path - val outFile = file + val outFile = File(tmpFile.absolutePath+"/"+relativePath) + if (!outFile.parentFile.exists()){ + outFile.parentFile.mkdirs() + } + if (!outFile.exists()){ + outFile.createNewFile() + } + val tmpFile = TmpFile(file,outFile) + tempFiles.add(tmpFile) val methodsRecord: HashMap? = WovenInfoUtils.getClassMethodRecord(file.absolutePath) if (methodsRecord != null){ FileInputStream(file).use { inputs -> @@ -428,6 +437,13 @@ class CompileAndroidAopTask(val allJars: MutableList, WovenIntoCode.createInitClass(output) } + for (tempFile in tempFiles) { + tempFile.tmp.inputStream().use { inputStream -> + inputStream.copyTo(FileOutputStream(tempFile.target)) + } +// tempFile.tmp.copyTo(tempFile.target,true) + } + exportCutInfo() } diff --git a/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/beans/TmpFile.kt b/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/beans/TmpFile.kt new file mode 100644 index 00000000..a0f44da6 --- /dev/null +++ b/android-aop-plugin/src/main/kotlin/com/flyjingfish/android_aop_plugin/beans/TmpFile.kt @@ -0,0 +1,5 @@ +package com.flyjingfish.android_aop_plugin.beans + +import java.io.File + +class TmpFile(val target: File, val tmp :File) \ No newline at end of file