Proguard: Keep annotation of specific method

ε祈祈猫儿з 提交于 2020-01-04 02:28:05

问题


Have have this class in my Minecraft Bukkit plugin:

public class AsyncPlayerChatListener implements Listener
{
    @EventHandler(priority = EventPriority.HIGH)
    public void onEvent(AsyncPlayerChatEvent event)
    {
    }
}

And I want to keep the method along with its annotation. This is my current proguard configuration:

-keep class * extends org.bukkit.event.Listener {
    @org.bukkit.event.EventHandler <methods>;
}

ProGuard currently keeps the method and removes the annotation. How can I specify to keep all EventHandler annotations in classes implementing Listener (or all EventHandler annotation anywhere, would be fine too)?

I know

-keepattributes *Annotation*

exists, but I guess this would make ProGuard keep any annotation anywhere.


回答1:


I was unforunately unable to test this, but this may help(?):

-keepclassmembers class * extends org.bukkit.event.Listener {
    @org.bukkit.event.EventHandler public *;
}


来源:https://stackoverflow.com/questions/35495185/proguard-keep-annotation-of-specific-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!