osgi - Proguard 保留选项来处理 OSGi 声明式服务
问题描述
什么是用于 OSGi 声明式服务与 Proguard 混淆的 keep 选项
参考下面的例子,我需要保留DS相关功能而不用Proguard删除它,因为它找不到参考
@Component
public class RandomApp {
private RandomGenApi randomGenApi;
@Reference
public void setRandomGenService(RandomGenApi randomGenApi) {
this.randomGenApi = randomGenApi;
}
@Activate
void startRandomApp() {
System.out.println("Startig RandomApp...");
}
解决方案
我可以通过将 OSGi 服务定义为入口点来实现这一点。这是要定义的保留选项
#Keep annotations.
-keepattributes *Annotation*
#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 *;
}
推荐阅读
- sql - 使用开始和结束时间报告时间信息
- sql-server - 如何通过 PYTHON 为 SQL INSERT FROM OPENJSON 转义 JSON 响应中的字符
- regex - Kotlin 正则表达式边界匹配不起作用
- list - How can I compare the value of two predicates prolog
- docker - 如何构建一个可以在busybox中运行我的c++程序的docker构建文件?
- python - How to get instagram number of followers using instaload?
- c++ - 如何在 C++ 的控制台中结束输入多行?
- php - 显示登录用户的评论总数( $user_id = get_current_user_id(); )
- microsoft-graph-api - How to filter SharePoint list items by ID using Microsoft Graph Api
- c++ - Access violation when attempting to access object member variables in an array