BrunoBonacci / lein-binplus

A Leiningen plugin for producing standalone console executables that work on OS X, Linux, and Windows.
68 stars 5 forks source link

Simple seesaw app is blocking during lein bin command #11

Closed caumond closed 4 years ago

caumond commented 4 years ago

Find below a very simple seesaw code. The plugin is blocking, just after the "Compiling app.core" message. If I lein run, this is working. If I refactor that code, the bug start to disappear, especially the pack! method .

(ns app.core
  (:use seesaw.core)
  (:gen-class)
  )

(def fenetre 
  (frame :content (label "coucou"))
  )

(config! fenetre
         :content (button :text "test"))
(pack! fenetre) 

(defn -main [& args]
  (invoke-later
    (-> fenetre
     pack!
     show!)))
BrunoBonacci commented 4 years ago

Hi @caumond ,

I suppose the issue lies with the compilation-time vs run-time. lein-binplus will run AOT compilation (like uberjar) With the AOT compilation your namespace will be loaded (and compile). Some of the expressions in the snippet above seem to be designed be executed a runtime (such (pack! fenetre), (config! fenetre ...) and potentially (def fenetre ...)

for example if you run lein compile :all it will run the compilation-only of all your namespaces. I suspect you will see the same result.

I'm not familiar with the Seesaw library however I assume you define your UI in a function which will be executed a runtime

like:

;; EXAMPLE NOT TESTED
(ns app.core
  (:use seesaw.core)
  (:gen-class))

;; this is executed in the main
(defn fenetre 
  []
  (frame :content (label "coucou")))

(defn -main [& args]
  (invoke-later
    (-> (fenetre)
     pack!
     show!)))
caumond commented 4 years ago

Hi @BrunoBonacci, Apologies for my lack of politeness, it is not my habit, social network effect, (;p

Thanks for your quick answer, this is the right solution: 1) I did not notice my java window process was launched during the compile time (even if the window is not), if I kill the java process, the compilation process continues. 2) I definitely have to refactor my example, I am new to clojure... My code was born in a REPL, so I copy paste it too directly. 3) I suggest you mention this lein compile :alltest in the readme, to help your users to better understand their issue.

Anthony