From 7a32c50d757fcea5518d8497c3da7579a59a2c74 Mon Sep 17 00:00:00 2001 From: "Kevin J. Lynagh" Date: Sun, 1 Apr 2012 14:56:52 -0700 Subject: [PATCH] Add hook to run cljx before `lein jar`. --- .gitignore | 2 ++ README.markdown | 15 ++++++++------- src/cljx/hooks.clj | 11 +++++++++++ src/leiningen/cljx.clj | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 src/cljx/hooks.clj diff --git a/.gitignore b/.gitignore index 1b2ab46..6b18f3b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ lib/ .lein* test/generated +pom.xml +target/ diff --git a/README.markdown b/README.markdown index 9d02a63..65448ff 100644 --- a/README.markdown +++ b/README.markdown @@ -27,6 +27,14 @@ To use it, add it to your `project.clj`: :rules cljx.rules/cljs-rules}]} ``` +Add + +```clojure +:hooks [cljx.hooks] +``` + +to automatically run cljx before cutting a JAR. + The included clj and cljs rule sets will remove forms marked with platform-specific metadata and rename protocols as appropriate. E.g., the `.cljx` source containing @@ -89,10 +97,3 @@ Misc ---- Emacs users, want syntax highlighting? Add to your emacs config: `(add-to-list 'auto-mode-alist '("\\.cljx\\'" . clojure-mode))`. - - - -Todo ----- - -+ Hook into cljsbuild + jar processes diff --git a/src/cljx/hooks.clj b/src/cljx/hooks.clj new file mode 100644 index 0000000..2607363 --- /dev/null +++ b/src/cljx/hooks.clj @@ -0,0 +1,11 @@ +(ns cljx.hooks + (:require leiningen.cljx + [robert.hooke :as hooke] + [leiningen.jar :as ljar])) + +(defn- jar-hook [task project] + (leiningen.cljx/cljx project) + (task project)) + +(defn activate [] + (hooke/add-hook #'ljar/jar #'jar-hook)) diff --git a/src/leiningen/cljx.clj b/src/leiningen/cljx.clj index ab8772d..b994f99 100644 --- a/src/leiningen/cljx.clj +++ b/src/leiningen/cljx.clj @@ -10,7 +10,7 @@ (defn cljx "Statically transform .cljx files into Clojure and ClojureScript sources." - [project & args] + [project] (if-let [opts (:cljx project)] (if-let [{builds :builds} opts]