如何使用 ProGuard 混淆 OSGi 包?

发布于 2024-07-14 21:18:15 字数 430 浏览 6 评论 0原文

我目前正在尝试使用 ProGuard 来混淆我的 Eclipse RCP 应用程序。 问题是它混淆了包名称(类 My.Package.Class 变成类似 abc 的东西),但将包名称保留在 MANIFEST.MF 的 Export-Package 部分中。

这导致我的应用程序(实际上是一组 OSGi 捆绑包)无法运行,因为无法解析 MANIFEST.MF 的 Export-Package 部分中指定的包名称。

有人使用 ProGuard 混淆基于 OSGi 的 RCP 应用程序取得过成功吗? 基本上,我看到两个选择:要么完全关闭包名称混淆,要么混淆 MANIFEST.MF 的 Export-Package 部分,但我找不到实现其中任何一个的方法。 Proguard 似乎仅混淆 MANIFEST.MF 中的 Bundle-Activator 类名称,跳过所有其他部分。 提前致谢!

I am currently trying to obfuscate my Eclipse RCP application with ProGuard. The problem is that it obfuscates the package names (the class My.Package.Class turns into something like a.b.c), but keeps the package names in the Export-Package section of MANIFEST.MF.

This leads to the fact that my application (which is a set of OSGi-bundles, actually) cannot be run, as the package names specified in Export-Package section of MANIFEST.MFs cannot be resolved.

Has anybody had any success with ProGuard obfuscating an OSGi-based RCP application? Basically, I see two choices: either completely turn off package names obfuscation, or obfucate MANIFEST.MF's Export-Package section, but I can't find the way to implement any of them. Proguard seems to obfuscate only Bundle-Activator class name in MANIFEST.MF, skipping all other sections. Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无法言说的痛 2024-07-21 21:18:15

关闭包名混淆; 我的意思是,您通过告诉世界软件包名称来揭示什么重要的商业价值?

如果这确实是一个问题,请将所有代码移至完全混淆的库中,并在非混淆的插件中使用该库。

也就是说,请考虑不要在混淆上浪费时间。 这会花费你的时间和金钱,而且是否有任何好处值得怀疑。 当你的竞争对手开始拆解你有价值的作品时,你将编写下一个版本。 那为什么还要麻烦呢?

Turn off package name obfuscation; I mean what important business values are you exposing by telling the world the package names?

If that really is an issue, move all code into a fully obfuscated library and use the library in a non-obfuscated plugin.

That said, consider not wasting your time with obfuscation at all. It will cost you time and money and it's questionable whether there is any benefit. At the time when your competitors have started to disassemble your valuable work, you will be writing the next version. So why bother?

小草泠泠 2024-07-21 21:18:15

ProGuard 不支持内置 OSGi 捆绑混淆。
查看 Proguard 功能请求 #135 了解更多信息。

OSGi bundle obfuscation is not supported built-in by ProGuard.
Check the Proguard feature request #135 for more info.

没︽人懂的悲伤 2024-07-21 21:18:15

对 OSGI 声明性服务使用以下保留选项

#Keep all annotations.
-keepattributes *Annotation*,Exceptions
#Keep all interfaces. This is required to run OSGi services.
-keep public interface *
#Keep all Component classes
-keep @org.osgi.service.component.annotations.Component class *
#Kepp all Component classes member functions with OSGi specific annotations
-keepclassmembers @org.osgi.service.component.annotations.Component class * {
   #Keep all methods with annotatios Reference.
   @org.osgi.service.component.annotations.Reference *;
   #Keep all methods with annotatios Activate.
   @org.osgi.service.component.annotations.Activate *;
}

Use the following keep options for the OSGI declarative service

#Keep all annotations.
-keepattributes *Annotation*,Exceptions
#Keep all interfaces. This is required to run OSGi services.
-keep public interface *
#Keep all Component classes
-keep @org.osgi.service.component.annotations.Component class *
#Kepp all Component classes member functions with OSGi specific annotations
-keepclassmembers @org.osgi.service.component.annotations.Component class * {
   #Keep all methods with annotatios Reference.
   @org.osgi.service.component.annotations.Reference *;
   #Keep all methods with annotatios Activate.
   @org.osgi.service.component.annotations.Activate *;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文