问题描述
我了解 保持 ProGuard 的选项 可以与通配符一起使用以包含完整的命名空间.例如:
I understand that the keep options of ProGuard can be used with wildcards to include full namespaces. E.g.:
-keepclassmembers class com.yourcompany.yourpackage.** {
# relevant configuration
}
是否可以将相同的配置应用于多个命名空间而不必重复配置两次?
Can the same configuration be applied to multiple namespaces without having to repeat the configuration twice?
例如,是否可以同时包含 io.
和 com.
命名空间?
For example, is something like the following possible to include both the io.
and com.
namespace?
-keepclassmembers class [com|io].yourcompany.yourpackage.** {
# relevant configuration
}
推荐答案
这由 ProGuard 决定类规范.
模拟正则表达式的有限选项可用.但是,这些不包括通常用于表示选项的管道 (|
).
Limited options, mimicking regular expressions, are available. But, these do not include the pipe (|
) typically used for denoting options.
然而,"[f] 或额外的灵活性,类名实际上可以是类名的逗号分隔列表,带有可选的 !
否定符,就像文件名过滤器一样.这种表示法看起来不太像 Java,因此应该适度使用."
However, "[f]or additional flexibility, class names can actually be comma-separated lists of class names, with optional !
negators, just like file name filters. This notation doesn't look very Java-like, so it should be used with moderation."
谁在乎看起来不是很像 Java",我只是不想重复自己.此外,我正在使用 Kotlin.=) 以下应该有效:
Who cares about not looking very "Java-like", I just don't want to repeat myself. Besides, I'm using Kotlin. =) The following should thus work:
-keepclassmembers class com.yourcompany.yourpackage.**, io.yourcompany.yourpackage.** {
# relevant configuration
}
这篇关于如何为多个命名空间配置 ProGuard 保留选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!