我想知道是否有人有使用 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 的桌面应用程序。
提前致谢。