I'm trying to make single executable *.jar via proguard plugin for sbt 10.*.
All seems to be okay, except that sbt-proguard doesn't include java jars (in my case mysql-connector-java-5.1.10.jar) cause when I'm trying to run output jar with
java -jar proguard-output.min.jar
I'm getting
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
I've tried to leverage that problem by adding jar explicitly in build.sbt:
proguardInJars += Path.userHome / ".m2" / "repository" / "mysql" / "mysql-connector-java" / "5.1.10" / "mysql-connector-java-5.1.10.jar"
moreover in proguard log:
...
Preparing output jar
...
Copying resources from program jar [/home/kostya/.m2/repository/mysql/mysql-connector-java/5.1.10/mysql-conn开发者_StackOverflowector-java-5.1.10.jar] (filtered)
...
But I'm still getting the same exception. What am I doing wrong?
The class is specified in the input, but the code only instantiates it by introspection, which ProGuard can't know. You therefore have to specify explicitly that it has to be preserved in the output.
Cfr. ProGuard manual > Examples > Processing database drivers
Cfr. ProGuard manual > Troubleshooting > ClassNotFoundException
A safer solution is probably not to process third-party jars like the JDBC driver, but to specify them as library jars instead.
精彩评论