aroemers / mount-lite

mount, but different and light
https://cljdoc.org/d/functionalbytes/mount-lite/
Eclipse Public License 1.0
102 stars 8 forks source link

Question: does mount-lite work with aot compilation? #10

Closed ekroon closed 7 years ago

ekroon commented 8 years ago

We are having some issues with defstate declarations in a namespace containing a -main function (with (:gen-class) statement and aot configured in leiningen). When creating an uberjar this will not start the component.

Workaround for this: create uberjar without aot and run with java -cp uber.jar clojure.main -m your.namespace.to.main

aroemers commented 8 years ago

Hi @ekroon. There used to be an issue with AOT compliation indeed, see https://github.com/aroemers/mount-lite/issues/7. That issue was solved, but maybe it has returned because of new changes. I will investigate this later.

ekroon commented 8 years ago

additional information: it seems like that the ::order keyword does not get set on the meta-data when the namespace is AOT compiled. I will investigate this more, and check #7

ekroon commented 8 years ago

I created PR #11 which fixes the problem. I think adding ::order on runtime should not create other problems, and tests succeed, but if you need more information / tests please say so. I will look into adding AOT compilation tests to circle ci if necessary.

aroemers commented 7 years ago

After more investigation in the out-of-band-provided example code, it seems that the issue was with a circular namespace dependency, somewhat like this:

(ns foo 
  (:use mount.lite)
  (:gen-class))

(defstate foo :start "foo")

(defn -main [& args]
  (require 'bar)
  (start)
  ...)
(ns bar
  (:require foo)
  (:use mount.lite))

(defstate bar :start (println foo/foo))

Removing the circular namespace dependency solved the issue.