From 5201338e4207157c71edbde06062b07d51d98a72 Mon Sep 17 00:00:00 2001 From: typ0520 Date: Wed, 29 Nov 2017 17:04:49 +0800 Subject: [PATCH] fix miss file in assets --- CHANGELOG.md | 6 +++++ README.md | 2 +- .../build/util/FastdexInstantRun.groovy | 25 +++++++++++++++--- gradle.properties | 2 +- sample/app/build.gradle | 26 +++++++++---------- sample/app/src/main/assets/font/cn/haha.txt | 1 + sample/app/src/main/assets/font/xx.txt | 1 + sample/app/src/main/assets/html/index.html | 1 + sample/build.gradle | 2 +- 9 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 sample/app/src/main/assets/font/cn/haha.txt create mode 100644 sample/app/src/main/assets/font/xx.txt create mode 100644 sample/app/src/main/assets/html/index.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f12e0a8..e8d10c07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.8.4 (2017-11-29) + +Bugfixes: + + - 修复assets目录下的子目录的内容没有被打进补丁资源包的问题 + ## 0.8.3 (2017-11-27) Bugfixes: diff --git a/README.md b/README.md index 908b1917..f90e1df0 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Android API 9(2.3)+ ; android-gradle-build 2.0.0+ } dependencies { - classpath 'com.github.typ0520:fastdex-gradle:0.8.3' + classpath 'com.github.typ0520:fastdex-gradle:0.8.4' } } ```` diff --git a/fastdex-gradle/src/main/groovy/fastdex/build/util/FastdexInstantRun.groovy b/fastdex-gradle/src/main/groovy/fastdex/build/util/FastdexInstantRun.groovy index b53d1189..174d0e92 100644 --- a/fastdex-gradle/src/main/groovy/fastdex/build/util/FastdexInstantRun.groovy +++ b/fastdex-gradle/src/main/groovy/fastdex/build/util/FastdexInstantRun.groovy @@ -4,7 +4,13 @@ import com.android.ddmlib.AndroidDebugBridge import com.android.ddmlib.IDevice import fastdex.build.variant.FastdexVariant import fastdex.common.utils.FileUtils +import org.apache.tools.ant.taskdefs.condition.Os import org.gradle.api.Project +import java.nio.file.FileVisitResult +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.SimpleFileVisitor +import java.nio.file.attribute.BasicFileAttributes /** * Created by tong on 17/3/12. @@ -250,11 +256,22 @@ class FastdexInstantRun { if (dir.listFiles().length == 0) { return result } - for (File file : dir.listFiles()) { - if (file.isFile() && !file.getName().startsWith(".")) { - result.add(file.getName()) + + boolean isWindows = Os.isFamily(Os.FAMILY_WINDOWS) + Path path = dir.toPath() + Files.walkFileTree(path, new SimpleFileVisitor() { + @Override + FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { + if (!file.toFile().isHidden()) { + String relativePath = path.relativize(file).toString() + if (isWindows) { + relativePath = relativePath.replaceAll("\\\\","/") + } + result.add(relativePath) + } + return FileVisitResult.CONTINUE } - } + }) return result } diff --git a/gradle.properties b/gradle.properties index 99a83f36..a5ebb5d1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,7 +20,7 @@ org.gradle.daemon=true groupId=com.github.typ0520 -version=0.8.3 +version=0.8.4 ANDROID_BUILD_MIN_SDK_VERSION=14 ANDROID_BUILD_TARGET_SDK_VERSION=22 diff --git a/sample/app/build.gradle b/sample/app/build.gradle index 92ebe0af..1cb588a5 100644 --- a/sample/app/build.gradle +++ b/sample/app/build.gradle @@ -79,19 +79,19 @@ android { } } - productFlavors { - flavor1 { - if (com.android.builder.model.Version.ANDROID_GRADLE_PLUGIN_VERSION.compareTo("3.0") >= 0) { - flavorDimensions "versionCode" - } - } - - flavor2 { - if (com.android.builder.model.Version.ANDROID_GRADLE_PLUGIN_VERSION.compareTo("3.0") >= 0) { - flavorDimensions "versionCode" - } - } - } +// productFlavors { +// flavor1 { +// if (com.android.builder.model.Version.ANDROID_GRADLE_PLUGIN_VERSION.compareTo("3.0") >= 0) { +// flavorDimensions "versionCode" +// } +// } +// +// flavor2 { +// if (com.android.builder.model.Version.ANDROID_GRADLE_PLUGIN_VERSION.compareTo("3.0") >= 0) { +// flavorDimensions "versionCode" +// } +// } +// } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 diff --git a/sample/app/src/main/assets/font/cn/haha.txt b/sample/app/src/main/assets/font/cn/haha.txt new file mode 100644 index 00000000..819cc449 --- /dev/null +++ b/sample/app/src/main/assets/font/cn/haha.txt @@ -0,0 +1 @@ +haha \ No newline at end of file diff --git a/sample/app/src/main/assets/font/xx.txt b/sample/app/src/main/assets/font/xx.txt new file mode 100644 index 00000000..d6459e00 --- /dev/null +++ b/sample/app/src/main/assets/font/xx.txt @@ -0,0 +1 @@ +xxx diff --git a/sample/app/src/main/assets/html/index.html b/sample/app/src/main/assets/html/index.html new file mode 100644 index 00000000..64233a9e --- /dev/null +++ b/sample/app/src/main/assets/html/index.html @@ -0,0 +1 @@ +index.html \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index b1cd62a4..10fd6d79 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -14,7 +14,7 @@ buildscript { classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' classpath "me.tatarka:gradle-retrolambda:3.7.0" classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1' - classpath 'com.github.typ0520:fastdex-gradle:0.8.3' + classpath 'com.github.typ0520:fastdex-gradle:0.8.4' } }