uberjar and resource

182 views
Skip to first unread message

Miki Tebeka

unread,
Mar 17, 2011, 5:17:09 PM3/17/11
to comp...@googlegroups.com
Greetings,

I have compojure application that have CSS and JS files in "public".
In the code is have (wrap-file "public") in my code and when running the application with "lein run" it works well.
However when I try to pack it with "lein uberjar" it can't find the resources.

I've tried   :resources-path "public" in project.clj but the files are place in the root of the jar. And when I tried with (wrap-file ".") but still get 404.

Any ideas on how to pack "static" resources in an uberjar?

Thanks,
--
Miki

James Reeves

unread,
Mar 17, 2011, 5:34:04 PM3/17/11
to comp...@googlegroups.com
On 17 March 2011 21:17, Miki Tebeka <miki....@gmail.com> wrote:
> I have compojure application that have CSS and JS files in "public".
> In the code is have (wrap-file "public") in my code and when running the
> application with "lein run" it works well.

The wrap-file middleware only serves static files, not resources
bundled with the jar or war file.

Instead, use the compojure.route/resources function. Take a look at
the compojure-example project for a complete demonstration:

https://github.com/weavejester/compojure-example

In general, it's more idiomatic Compojure to use the compojure.route
functions instead of middleware to serve files.

- James

Miki Tebeka

unread,
Mar 17, 2011, 5:57:44 PM3/17/11
to comp...@googlegroups.com
Worked like a charm, thank you!
Reply all
Reply to author
Forward
0 new messages