我如何缩小 SNMP4J 库以提取陷阱发送功能

How can i shrink SNMP4J library to extract trap sending feature

我想要 SNMP4j 的一个特定功能(陷阱),有没有办法获得一个只有这个功能的新 jar?

我们可以为此功能使用混淆器。

1 从 https://sourceforge.net/projects/proguard/

下载混淆器

2 在 proguard 的 libs 文件夹中创建一个文件(shrink.pro)并粘贴以下行

-injars      snmp.jar 
-outjars     out.jar 
-libraryjars <java.home>/lib/rt.jar
-printmapping out.map 

-dontwarn
-ignorewarnings
-keepattributes

-keep public class org.snmp4j.smi.OID
-keep public class org.snmp4j.CommunityTarget
-keep public class org.snmp4j.smi.UdpAddress
-keep public class org.snmp4j.TransportMapping
-keep public class org.snmp4j.smi.OctetString
-keep public class org.snmp4j.smi.Variable
-keep public class org.snmp4j.transport.DefaultUdpTransportMapping
-keep public class org.snmp4j.smi.Address
-keep public class org.snmp4j.PDUv1
-keep public class org.snmp4j.smi.VariableBinding
-keep public class org.snmp4j.Snmp
-keep public class org.snmp4j.PDU
-keep public class org.snmp4j.ScopedPDU
-keep public class org.snmp4j.UserTarget
-keep public class org.snmp4j.mp.MPv3
-keep public class org.snmp4j.mp.SnmpConstants
-keep public class org.snmp4j.security.AuthMD5
-keep public class org.snmp4j.security.PrivDES
-keep public class org.snmp4j.security.SecurityLevel
-keep public class org.snmp4j.security.SecurityModel
-keep public class org.snmp4j.security.SecurityModels
-keep public class org.snmp4j.security.SecurityProtocols
-keep public class org.snmp4j.security.USM
-keep public class org.snmp4j.security.UsmUser
-keep public class org.snmp4j.smi.IpAddress

3 运行 以下命令

java -jar proguard.jar @shrink.pro

4 您将在 proguard 的 libs 文件夹中获得新的 jar。