From 10de18643b3968dd65ba1f2a4d01e096cfa7fc89 Mon Sep 17 00:00:00 2001 From: xujun Date: Mon, 1 Nov 2021 16:21:27 +0800 Subject: [PATCH 1/3] fix incremental build - zip file is empty --- .../kotlin/com/tencent/matrix/plugin/trace/MatrixTrace.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/trace/MatrixTrace.kt b/matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/trace/MatrixTrace.kt index 3c6ab5c11..8ac89e6f9 100644 --- a/matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/trace/MatrixTrace.kt +++ b/matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/trace/MatrixTrace.kt @@ -286,7 +286,13 @@ class MatrixTrace( val outChangedFiles = HashMap() for ((changedFileInput, status) in mapOfChangedFiles) { val changedFileInputFullPath = changedFileInput.absolutePath - val changedFileOutput = File(changedFileInputFullPath.replace(inputFullPath, outputFullPath)) + + val changedFileOutput = if (changedFileInputFullPath.contains(inputFullPath)){ + File(changedFileInputFullPath.replace(inputFullPath, outputFullPath)) + } else { // if not contains, changedFileOutput should be modify, else when we read and write the same file, the jar would be empty + File(outputFullPath, changedFileInput.name) + } + if (status == Status.ADDED || status == Status.CHANGED) { resultOfDirInputToOut[changedFileInput] = changedFileOutput } else if (status == Status.REMOVED) { From dc61e80bf9e1528b63d076c33e450ecbbb19ef3d Mon Sep 17 00:00:00 2001 From: xujun Date: Tue, 9 Nov 2021 15:08:01 +0800 Subject: [PATCH 2/3] fix incremental build - zip file is empty --- .../com/tencent/matrix/plugin/trace/MatrixTrace.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/trace/MatrixTrace.kt b/matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/trace/MatrixTrace.kt index 8ac89e6f9..71c23aee6 100644 --- a/matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/trace/MatrixTrace.kt +++ b/matrix/matrix-android/matrix-gradle-plugin/src/main/kotlin/com/tencent/matrix/plugin/trace/MatrixTrace.kt @@ -284,15 +284,17 @@ class MatrixTrace( if (isIncremental) { val outChangedFiles = HashMap() + for ((changedFileInput, status) in mapOfChangedFiles) { val changedFileInputFullPath = changedFileInput.absolutePath - val changedFileOutput = if (changedFileInputFullPath.contains(inputFullPath)){ - File(changedFileInputFullPath.replace(inputFullPath, outputFullPath)) - } else { // if not contains, changedFileOutput should be modify, else when we read and write the same file, the jar would be empty - File(outputFullPath, changedFileInput.name) + // mapOfChangedFiles is contains all. each collectDirectoryInputTask should handle itself, should not handle other file + if (!changedFileInputFullPath.contains(inputFullPath)) { + continue } + val changedFileOutput = File(changedFileInputFullPath.replace(inputFullPath, outputFullPath)) + if (status == Status.ADDED || status == Status.CHANGED) { resultOfDirInputToOut[changedFileInput] = changedFileOutput } else if (status == Status.REMOVED) { From da2465e96e6e33ecbf776f68c4714e83a7fc81d9 Mon Sep 17 00:00:00 2001 From: Cyrus Date: Thu, 2 Dec 2021 11:35:59 +0800 Subject: [PATCH 3/3] add file extension for apksigner&zipalign in Windows --- samples/sample-android/app/build.gradle | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/samples/sample-android/app/build.gradle b/samples/sample-android/app/build.gradle index 9c2372380..374a37d2c 100644 --- a/samples/sample-android/app/build.gradle +++ b/samples/sample-android/app/build.gradle @@ -165,8 +165,8 @@ matrix { sevenZipPath = "${project.configurations.sevenZipDependency.resolve().getAt(0).getAbsolutePath()}" //Notice: You need to modify the value of $apksignerPath on different platform. the value below only suitable for Mac Platform, //if on Windows, you may have to replace apksigner with apksigner.bat. - apksignerPath = "${android.getSdkDirectory().getAbsolutePath()}/build-tools/${android.getBuildToolsVersion()}/apksigner" - zipAlignPath = "${android.getSdkDirectory().getAbsolutePath()}/build-tools/${android.getBuildToolsVersion()}/zipalign" + apksignerPath = "${android.getSdkDirectory().getAbsolutePath()}/build-tools/${android.getBuildToolsVersion()}/apksigner${isWindows() ? ".bat" : ""}" + zipAlignPath = "${android.getSdkDirectory().getAbsolutePath()}/build-tools/${android.getBuildToolsVersion()}/zipalign${isWindows() ? ".exe" : ""}" ignoreResources = ["R.id.*", "R.bool.*", "R.layout.unused_layout"] } } @@ -186,3 +186,12 @@ project.tasks.whenTaskAdded { } } } + +def isWindows() { + try { + String os = System.getProperty("os.name").toLowerCase() + return os.indexOf("win") >= 0 + } catch (Exception ignored) { + return false + } +} \ No newline at end of file