我想知道是否有人有使用proguard混淆他们使用leiningen编译的uberjars的经验。我已尽力在Google上寻找解决方案,但实在找不到答案。我想知道这是否可能。
我一直在尝试混淆一个默认的lein项目。这是core.clj文件:
(ns proguard.core
(:gen-class))
(defn -main
"I don't do a whole lot."
[& args]
(println "Hello, World!"))
项目文件:
(defproject proguard "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.4.0"]]
:aot :all
:main proguard.core)
我的Proguard配置文件:
-injars clojure/proguard/target/proguard-0.1.0-SNAPSHOT-standalone.jar
-outjars clojure/test-project
-libraryjars /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/rt.jar
-dontshrink
-dontoptimize
-dontusemixedcaseclassnames
-dontpreverify
-dontnote
-printseeds
-keepclasseswithmembers public class * {
public static void main(java.lang.String[]);
}
-keep class clojure.core__init { public static void load(); }
-keep class clojure.core_proxy__init { public static void load(); }
-keep class clojure.core_print__init { public static void load(); }
-keep class clojure.genclass__init { public static void load(); }
-keep class clojure.core_deftype__init { public static void load(); }
-keep class clojure.core.protocols__init { public static void load(); }
-keep class clojure.gvec__init { public static void load(); }
-keep class clojure.java.io__init { public static void load(); }
-keep class clojure.lang__init { public static void load(); }
-keep class proguard.core__init {
public static void load();
}
-keep class proguard.core {
public *** super*(...);
}
每当我尝试运行混淆后的jar文件时,会出现以下错误:
Exception in thread "main" java.lang.ExceptionInInitializerError
at clojure.lang.ve.<init>(Unknown Source)
at clojure.lang.ve.c(Unknown Source)
at clojure.lang.yf.a(Unknown Source)
at proguard.core.<clinit>(Unknown Source)
Caused by: java.lang.ClassNotFoundException: clojure.lang.PersistentList, compiling:(clojure/core.clj:20)
at clojure.lang.at.a(Unknown Source)
at clojure.lang.at.b(Unknown Source)
at clojure.lang.at.a(Unknown Source)
at clojure.lang.bj.a(Unknown Source)
at clojure.lang.at.a(Unknown Source)
at clojure.lang.at.b(Unknown Source)
at clojure.lang.at.a(Unknown Source)
at clojure.lang.at.a(Unknown Source)
at clojure.lang.at.a(Unknown Source)
at clojure.lang.xh.a(Unknown Source)
at clojure.lang.xh.a(Unknown Source)
at clojure.lang.xh.b(Unknown Source)
at clojure.lang.xh.d(Unknown Source)
at clojure.lang.xh.c(Unknown Source)
at clojure.lang.xh.<clinit>(Unknown Source)
... 4 more
Caused by: java.lang.ClassNotFoundException: clojure.lang.PersistentList
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at clojure.lang.ec.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at clojure.lang.xh.h(Unknown Source)
at clojure.lang.bp.b(Unknown Source)
at clojure.lang.bp.a(Unknown Source)
at clojure.lang.bq.a(Unknown Source)
... 19 more
我不太确定我在这里做错了什么...我尝试遵循一个Clojure针对Proguard的教程 (使用Proguard混淆),但是它是特定于Android和Ant的,因此我想知道对于使用Lein的桌面应用程序,这个过程是否完全不同。
提前感谢。
__init
类,就像你的配置文件中所显示的那样。我猜测你需要将clojure.jar添加到-libraryjars
列表中。 - Vladimir Matveev