Skip to content

Commit

Permalink
Merge pull request #60 from jstoneham/issue-59
Browse files Browse the repository at this point in the history
Support multiple war-resources-paths
  • Loading branch information
weavejester committed Apr 22, 2013
2 parents 938c886 + 0a7a143 commit 8b85769
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
12 changes: 8 additions & 4 deletions README.md
Expand Up @@ -176,12 +176,16 @@ and are optional values. If not supplied, default values will be used instead.
A war file can also include additional resource files, such as images or
stylesheets. These should be placed in the directory specified by the
Leiningen `:resources-path` key, which defaults to "resources". These
resources will be placed on the classpath.
resources will be placed on the classpath. To include multiple directories,
use the Leiningen `:resource-paths` key, which should be a vector. The
values in `:resources-path` and `:resource-paths` will be concatenated.

However, there is another sort of resource, one accessed through the
`ServletContext` object. These resources are usually not on the classpath,
and are instead placed in the root of the war file. If you happen to need this
functionality, you can place your files in the directory specified by the
`:war-resources-path` key, which defaules to "war-resources". It's recommended
that you only use WAR resources for compatibility with legacy Java interfaces;
under most circumstances, you should use the normal `:resources-path` instead.
`:war-resources-path` key, which defaults to "war-resources". (As with
normal resources, here you can use `:war-resource-paths` to include multiple
directories.) It's recommended that you only use WAR resources for
compatibility with legacy Java interfaces; under most circumstances, you
should use the normal `:resources-path` instead.
3 changes: 2 additions & 1 deletion src/leiningen/ring/uberwar.clj
Expand Up @@ -38,7 +38,8 @@
[(:resources-path project)] (:resource-paths project)))
:when path]
(war/dir-entry war-stream project "WEB-INF/classes/" path))
(war/dir-entry war-stream project "" (war/war-resources-path project))
(doseq [path (war/war-resources-paths project)]
(war/dir-entry war-stream project "" path))
(jar-entries war-stream project)))

(defn unmerge-profiles [project]
Expand Down
8 changes: 5 additions & 3 deletions src/leiningen/ring/war.clj
Expand Up @@ -180,8 +180,9 @@
(let [war-path (in-war-path war-root dir-path file)]
(file-entry war project war-path file))))

(defn war-resources-path [project]
(:war-resources-path project "war-resources"))
(defn war-resources-paths [project]
(filter identity
(distinct (concat [(:war-resources-path project "war-resources")] (:war-resource-paths project)))))

(defn write-war [project war-path]
(with-open [war-stream (create-war project war-path)]
Expand All @@ -192,7 +193,8 @@
[(:resources-path project)] (:resource-paths project)))
:when path]
(dir-entry war-stream project "WEB-INF/classes/" path))
(dir-entry war-stream project "" (war-resources-path project))
(doseq [path (war-resources-paths project)]
(dir-entry war-stream project "" path))
war-stream))

(defn add-servlet-dep [project]
Expand Down

0 comments on commit 8b85769

Please sign in to comment.