From 60fb39b71973860d1bfe409160d8305f77da019e Mon Sep 17 00:00:00 2001 From: dengxiaoyu Date: Tue, 9 Sep 2025 19:49:21 +0800 Subject: [PATCH] add obfuscation Signed-off-by: dengxiaoyu --- application/entry/build-profile.json5 | 15 +++++++++++++++ application/entry/obfuscation-rules.txt | 23 +++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 application/entry/obfuscation-rules.txt diff --git a/application/entry/build-profile.json5 b/application/entry/build-profile.json5 index 12369bde..f55ae85b 100644 --- a/application/entry/build-profile.json5 +++ b/application/entry/build-profile.json5 @@ -17,6 +17,21 @@ "apiType": "stageMode", "buildOption": { }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], "targets": [ { "name": "default", diff --git a/application/entry/obfuscation-rules.txt b/application/entry/obfuscation-rules.txt new file mode 100644 index 00000000..272efb6c --- /dev/null +++ b/application/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file -- Gitee