سؤال

With my Clojure/appengine-magic project, I currently start things up like this:

lein repl

(doto 'tlog.core require in-ns)
(compile 'tlog.core)
(ae/start tlog-app)
(require 'swank.swank) (swank.swank/start-repl 4005)

tlog.core has:

(:require [appengine-magic.core :as ae])

Alternatively, instead of ae/start, I could use, I think:

(use 'ring.adapter.jetty)
(run-jetty (var tlog.core/tlog-app-handler) {:port 8080})

I'd like to put all this behind a single command.

All attempts to handle this via a -main used with lein run or writing a leiningen plugin failed due to namespace/path issues.

So how can it be done?

هل كانت مفيدة؟

المحلول

Thanks to an example given by someone who preferred not to answer here, I now have a pretty good solution.

Addition to my project.clj:

:repl-init-script "src/tlog/init_repl.clj"

Will be triggered on running lein repl.

init-repl.clj:

(ns user
  "Init script for Leiningen REPL."
  (:require [appengine-magic.core :as ae])
  (:use [clojure.stacktrace]
        [clojure.contrib.repl-utils :only (show)]
        [tlog.core]))

(defn reload!
  "Force a reload of everything."
  []
  (require 'tlog.core :reload-all))

(compile 'tlog.core)
(ae/serve tlog-app)
(println "Interactive Jetty instance started. To force a reload: (reload!)")

(require 'swank.swank) (swank.swank/start-repl 4005)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top