Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edgargoncalves/543090 to your computer and use it in GitHub Desktop.
Save edgargoncalves/543090 to your computer and use it in GitHub Desktop.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; prepare our namespaces to the build-script:
(ns leiningen.deploy
(use [lancet :only [ant exec]] ; add other needed ant tasks here
[leiningen.uberjar :only [uberjar]] ; add other lein commands here
[leiningen.core :only [project]])) ; just so that we may call cmds
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; helper fns:
(defn call-external-ant
[target base-dir]
(println (apply str (take 80 (repeat "-"))))
(ant {:dir base-dir :target (name target) :inheritAll "true"})
(println (apply str (take 80 (repeat "-"))))
(println "... external ant task finished!"))
(defn run-shell-command
[cmd]
(exec {:executable cmd :spawn "true"}))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; the next fn should be callable with `lein deploy`.
(defn deploy
"Performs a set of steps, including ant tasks on other projs and shell cmds."
[project & args]
(uberjar project) ;; make an uberjar out of this clojure project
;; make one jar:
(println "Firing up 'ant jar' on an external project ...")
(call-external-ant :jar "/path/to/external/project/1/")
;; deploy to tomcat:
(println "firing up 'ant deploy' on another external project")
(call-external-ant :deploy "/path/to/external/project/2/")
;; kill tomcat, then fire up a fresh one:
(run-shell-command "shutdown.sh") ; assumes those two shell scripts in $PATH.
(run-shell-command "startup.sh"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment