I am developing a webapplication in Clojure and Vaadin, but I cannot get the application to autoredploy so that I just press refresh on the browser. Any ideas?
+1
A:
Ideally, you're using a REPL server that will allow you to load new Clojure code into your application at will. In that case, it's just a matter of changing your workflow to:
- notice problem
- go to Clojure editor
- Load new code into running application
- Go to browser, hit refresh.
If you're using Maven, you can use the maven-jetty-plugin to automatically reload your webapp when you change its source files. See this post for more info.
Yet another options is to continuously attempt to reload your Clojure code. Something like this, perhaps:
(defn reload
([] (reload #"."))
([ns-pattern]
(doseq [ns (all-ns)
:let [ns (.name ns)]
:when (re-seq ns-pattern (str ns))]
(require ns :reload))))
In whatever code you have that starts up your webapp, or in your main servlet init, etc., add something like:
(future (loop []
(Thread/sleep 5000)
(reload) ;; optionally specify a regex to match only your app's namespaces here
(recur)))
Definitely not something you want to use in production. I'd prefer using a proper remote REPL in every case, but the above will get you by.
Chas Emerick
2010-10-01 11:50:12
I tried this but it doesn't work with Vaadin. Could you give more details please?
Zubair
2010-10-01 13:17:03