Commits

Meikel Brandmeyer committed 2f23b75

Without AOT compilation just require the namespaces

This helps to stop compilation errors. It will also enable reflection
warnings even if not AOT compiled.

[#2 state:resolved tagged:committed]

Comments (0)

Files changed (2)

src/main/groovy/clojuresque/ClojureCompileTask.groovy

 
     private void initialise() {
         def action = [ execute: { ClojureCompileTask task ->
-            if (!task.project.aotCompile) {
-                return
-            }
-
+            boolean aotCompile = task.project.aotCompile
             boolean warnOnReflection = task.project.warnOnReflection
             Set<File> sourceDirs = task.sourceSet.srcDirs
             File destDir = task.destinationDir
                 sysproperty(key: "clojure.compile.path", value: destDir)
                 sysproperty(key: "clojure.compile.warn-on-reflection",
                     value: warnOnReflection)
+                sysproperty(key: "clojuresque.compile", value: aotCompile)
                 source.each {
                     arg(value: it)
                 }

src/main/java/clojuresque/ClojureCompile.java

     private static final IPersistentSet NS_FORMS =
         RT.set(Symbol.intern("ns"), Symbol.intern("clojure.core", "ns"));
 
+    private static final String DO_COMPILE_PROP = "clojuresque.compile";
     private static final Var compile = RT.var("clojure.core", "compile");
+    private static final Var require = RT.var("clojure.core", "require");
 
     private static Object findNamespace(Object form) {
         if (!(form instanceof ISeq))
         String compilePath = System.getProperty(COMPILE_PATH_PROP);
         boolean warnOnReflection =
             System.getProperty(WARN_ON_REFLECTION_PROP).equals("true");
+        boolean doCompile = System.getProperty(DO_COMPILE_PROP).equals("true");
 
         IPersistentMap threadBindings = RT.map(
                 COMPILE_PATH, compilePath,
                 try {
                     Object o = LispReader.read(rdr, false, null, false);
                     Object ns = findNamespace(o);
-                    if (ns != null && !seen.contains(ns))
-                        compile.invoke(ns);
+                    if (ns != null && !seen.contains(ns)) {
+                        if (doCompile)
+                            compile.invoke(ns);
+                        else
+                            require.invoke(ns);
+                    }
                     seen = (IPersistentSet)seen.cons(ns);
                 } finally {
                     rdr.close();