           (catch Exception e {}))))))
 
 (defn add-sdk-path
-  [project-map]
-  (assoc-in project-map
+  [project]
+  (assoc-in project
             [:android :sdk-path]
-            (or (get-in project-map [:android :sdk-path])
+            (or (get-in project [:android :sdk-path])
                 (utils/read-pref :android-sdk))))
 
 (defn create-file-from-template


(defn start-process-indirectly
  [process path & args]
  (let [project-map (read-project-clj path)
        java-cmd (or (:java-cmd project-map) (System/getenv "JAVA_CMD") "java")
        jar-file (-> (Class/forName class-name)
                     .getProtectionDomain
                     .getCodeSource

; low-level commands

(defn run-project-task
  [path project]
  (if (is-android-project? path)
    (doseq [sub-cmd ["build" "apk" "install" "run"]]
      (leiningen.droid/droid (add-sdk-path project) sub-cmd))
    (leiningen.run/run project)))

(defn run-repl-project-task
  [path project]
  (if (is-android-project? path)
    (doseq [sub-cmd ["doall" "repl"]]
      (leiningen.droid/droid (add-sdk-path project) sub-cmd)
      (Thread/sleep 10000))
    (leiningen.repl/repl project)))

(defn build-project-task
  [path project]
  (if (is-android-project? path)
    (-> (leiningen.droid/transform-into-release project)
        add-sdk-path
        leiningen.droid/execute-release-routine)
    (leiningen.uberjar/uberjar project)))

(defn test-project-task
  [path project]
  (leiningen.test/test project))

(defn clean-project-task
  [path project]
  (leiningen.clean/clean project))

(defn cljsbuild-project-task
  [path project]
  (leiningen.cljsbuild/cljsbuild project "auto"))

(defn hot-swap-project-task
  [path project]
  (when-let [conn (->> (Bootstrap/virtualMachineManager)
                       .attachingConnectors
                       (filter #(= (.name (.transport %)) "dt_socket"))
                       first)]
     (let [prm (.defaultArguments conn)
           stale-classes (doall (stale-java-classes project))]
       (.setValue (.get prm "port") debug-port)
       (.setValue (.get prm "hostname") "127.0.0.1")
       (when-let [vm (try (.attach conn prm) (catch Exception _))]
         (leiningen.javac/javac project)
         (->> stale-classes
              (create-class-map (.allClasses vm))
              (.redefineClasses vm))
