Skip to content

Commit

Permalink
Make war and uberwar compatible with v1.7.x :plugins usage
Browse files Browse the repository at this point in the history
  • Loading branch information
cemerick committed Mar 20, 2012
1 parent c1fcef7 commit 1d8ee65
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion project.clj
@@ -1,4 +1,4 @@
(defproject lein-ring "0.6.1" (defproject lein-ring "0.6.2-SNAPSHOT"
:description "Leiningen Ring plugin" :description "Leiningen Ring plugin"
:url "https://github.com/weavejester/lein-ring" :url "https://github.com/weavejester/lein-ring"
:dependencies [[org.clojure/clojure "1.2.1"] :dependencies [[org.clojure/clojure "1.2.1"]
Expand Down
20 changes: 16 additions & 4 deletions src/leiningen/ring/war.clj
@@ -1,8 +1,10 @@
(ns leiningen.ring.war (ns leiningen.ring.war
(:require [leiningen.compile :as compile] (:require leiningen.deps
[leiningen.compile :as compile]
[clojure.java.io :as io] [clojure.java.io :as io]
[clojure.string :as string]) [clojure.string :as string])
(:use [clojure.data.xml :only [sexp-as-element indent-str]]) (:use [leiningen.ring.server :only (eval-in-project)]
[clojure.data.xml :only [sexp-as-element indent-str]])
(:import [java.util.jar Manifest (:import [java.util.jar Manifest
JarEntry JarEntry
JarOutputStream] JarOutputStream]
Expand Down Expand Up @@ -115,12 +117,22 @@
(str ".clj")))) (str ".clj"))))


(defn compile-form [project namespace form] (defn compile-form [project namespace form]
;; We need to ensure that deps has already run before
;; we write anything to :target-dir, which is otherwise
;; cleaned by deps if it runs for the first time as a
;; side effect of eval-in-project
;; Ideally, generated sources would be going into a
;; dedicated directory and thus be immune from the lifecycle
;; around :target-dir; that would be straightforward using
;; lein 2.x middlewares, but not so easy with 1.x.
(leiningen.deps/deps project)
(let [out-file (source-file project namespace)] (let [out-file (source-file project namespace)]
(.mkdirs (.getParentFile out-file)) (.mkdirs (.getParentFile out-file))
(with-open [out (io/writer out-file)] (with-open [out (io/writer out-file)]
(binding [*out* out] (prn form)))) (binding [*out* out] (prn form))))
(compile/eval-in-project project (eval-in-project project
`(do (clojure.core/compile '~namespace) nil))) `(do (clojure.core/compile '~namespace) nil)
nil))


(defn generate-handler [project handler-sym] (defn generate-handler [project handler-sym]
(if (get-in project [:ring :servlet-path-info?] true) (if (get-in project [:ring :servlet-path-info?] true)
Expand Down

0 comments on commit 1d8ee65

Please sign in to comment.