我想要一个来自SNMP4j的特定功能(Traps),有没有办法获得一个只有这个功能的新jar?
答案 0 :(得分:1)
我们可以使用proguard来实现此功能。
1从https://sourceforge.net/projects/proguard/
下载proguard2在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。