 
 (defn update-task [task deps doc actions]
   {:pre [(every? dependency? deps) (every? fn? actions)]}
-  (let [task (or task {:actions [] :deps []})]
+  (let [task (or task {:actions [] :deps [] :run? (atom false)})]
     (-> task
         (update :deps    into deps)
         (update :doc     cat  doc)

                         :resources-path (str ~root "/resources")
                         :source-path    (str ~root "/src")
                         :test-path      (str ~root "/test"))))
         ; @the-project must be set before we include the tasks for bake to work.
         (require 'cake.tasks.defaults))))

(defn dependency? [form]

(defn remove-task! [name]
  (swap! tasks dissoc name))

(def project nil)
(def current-task nil)

(defn run-task
  "Execute the specified task after executing all prerequisite tasks."
  [form]
  (if (list? form)
    (binding [project @cake-project] ((eval form))) ; excute anonymous dependency
    (let [name form, task (@tasks name)]
      (when (nil? task) (abort "Unknown task:" name))
      (when-not @(:run? task)
        (doseq [dep (:deps task)] (run-task dep))
        (doseq [action (:actions task)]
          (binding [project @cake-project, current-task name]
            (action)))
        (compare-and-set! (get-in @tasks [name :run?]) false true)))))

(defmacro bake [& body]
  "Execute body in a fork of the jvm with the classpath of your project."
  (let [code (prn-str `(do (def ~'project '~(deref cake-project))
                           (def ~'opts ~opts)
                           ~@body))]
    `(do (require 'cake.ant)
