Skip to content

Commit

Permalink
Add hook to run cljx before lein jar.
Browse files Browse the repository at this point in the history
  • Loading branch information
lynaghk committed Apr 1, 2012
1 parent 8be8be1 commit 7a32c50
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1,3 +1,5 @@
lib/
.lein*
test/generated
pom.xml
target/
15 changes: 8 additions & 7 deletions README.markdown
Expand Up @@ -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

Expand Down Expand Up @@ -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
11 changes: 11 additions & 0 deletions 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))
2 changes: 1 addition & 1 deletion src/leiningen/cljx.clj
Expand Up @@ -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]
Expand Down

0 comments on commit 7a32c50

Please sign in to comment.