Skip to content

Commit

Permalink
Release 0.1.7 version, support resource file keep rule
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYeoh committed Aug 12, 2020
1 parent 762a2ec commit f980868
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,20 @@ private Map<String, String> obfuscateModuleEntries(BundleModule bundleModule, Ma
String bundleRawPath = bundleModule.getName().getName() + "/" + entry.getPath().toString();
String bundleObfuscatedPath = resourcesMapping.getEntryFilesMapping().get(bundleRawPath);
if (bundleObfuscatedPath == null) {
String fileSuffix = FileOperation.getFileSuffix(entry.getPath());
String obfuscatedName = guardStringBuilder.getReplaceString(mapping);
mapping.add(obfuscatedName);
bundleObfuscatedPath = obfuscateDir + "/" + obfuscatedName + fileSuffix;
resourcesMapping.putEntryFileMapping(bundleRawPath, bundleObfuscatedPath);
if (!shouldBeObfuscated(bundleRawPath)) {
System.out.println(String.format(
"[whiteList] find whiteList resource file, resource: %s",
bundleRawPath
));
return;
} else {
String fileSuffix = FileOperation.getFileSuffix(entry.getPath());
String obfuscatedName = guardStringBuilder.getReplaceString(mapping);
mapping.add(obfuscatedName);
bundleObfuscatedPath = obfuscateDir + "/" + obfuscatedName + fileSuffix;
resourcesMapping.putEntryFileMapping(bundleRawPath, bundleObfuscatedPath);
}
}

if (obfuscateEntries.values().contains(bundleObfuscatedPath)) {
throw new IllegalArgumentException(
String.format("Multiple entries with same key: %s -> %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,7 @@ public static void copyFileUsingStream(File source, File dest) throws IOExceptio
}

public static String getFileSimpleName(ZipPath zipPath) {
String fileName = zipPath.getName(zipPath.getNameCount() - 1).toString();
if (!fileName.contains(".")) {
return fileName;
}
String[] values = fileName.split(".");
return values[0];
return zipPath.getFileName().toString();
}

public static String getFileSuffix(ZipPath zipPath) {
Expand Down
16 changes: 11 additions & 5 deletions gradle/aabresguard.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@ if (!"true".equalsIgnoreCase(System.getProperty("enableAabResGuardPlugin", "fals

apply plugin: "com.bytedance.android.aabResGuard"
aabResGuard {
enableObfuscate = false
// mappingFile = file("../mapping.txt").toPath()
enableObfuscate = true
mappingFile = file("../mapping.txt").toPath()
whiteList = [
// keep resources
"*.R.raw.*",
"*.R.drawable.icon"
"*.R.drawable.icon",
"*.R.drawable.ic_*",
"*.R.anim.abc*",
"*.R.xml.actions",
// keep resource file
"*/res/xml/actions.xml",
]
obfuscatedBundleFileName = "duplicated-app.aab"
mergeDuplicatedRes = true
obfuscatedBundleFileName = "obfuscated-app.aab"
mergeDuplicatedRes = false
enableFilterFiles = true
filterList = [
"*/arm64-v8a/*"
Expand Down
2 changes: 1 addition & 1 deletion gradle/versions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ def versions = [:]
versions.agp = "3.5.0"
versions.kotlin = "1.3.61"
versions.java = "8"
versions.aabresguard = "0.1.6"
versions.aabresguard = "0.1.7"
// android
versions.compileSdkVersion = 28
versions.minSdkVersion = 15
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions samples/app/src/main/res/xml/actions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<action></action>

0 comments on commit f980868

Please sign in to comment.