Open paulbutcher opened 9 years ago
Can you provide your project file?
Sure:
(defproject annotator "0.1"
:source-paths ["src-clj"]
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/clojurescript "0.0-2371"]
[org.clojure/core.rrb-vector "0.0.11"]
[reagent "0.4.2"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"]
[compojure "1.2.0"]
[enlive "1.1.5"]
[cljs-ajax "0.3.3"]
[com.taoensso/timbre "3.3.1"]]
:plugins [[lein-ancient "0.5.5"]
[lein-cljsbuild "1.0.3"]
[lein-ring "0.8.11"]
[com.cemerick/clojurescript.test "0.3.1"]
[lein-zip "0.1.0"]]
:profiles {:production {:resource-paths ["target/production"]
:source-paths ["production/src-clj"]}
:dev {:resource-paths ["target/dev"]
:source-paths ["dev/src-clj"]}
:uberjar [:production {:aot :all}]}
:cljsbuild {:builds {:dev {:source-paths ["src-cljs"]
:compiler {:output-dir "target/dev/public/js"
:output-to "target/dev/public/js/main.js"
:optimizations :whitespace
:pretty-print true
:source-map "target/dev/public/js/main.map"}}
:production {:source-paths ["src-cljs"]
:compiler {:output-to "target/production/public/js/main.min.js"
:optimizations :advanced
:externs ["react/react.js"
"externs/jquery-1.9.js"
"externs/twitter-bootstrap.js"]
:closure-warnings {:check-useless-code :off}
:pretty-print false}}
:test {:source-paths ["src-cljs" "test-cljs"]
:compiler {:output-to "target/test/js/unit-test.js"
:preamble ["reagent/react.js"]
:optimizations :whitespace
:pretty-print true}}}
:test-commands {"unit-tests" ["phantomjs" :runner
"resources/private/bind-polyfill.js"
"target/test/js/unit-test.js"]}}
:zip ["Dockerfile"
"target/annotator-0.1-standalone.jar"]
:ring {:init annotator.core/init
:handler annotator.core/handler})
Okay, I see the issue. Looks like the function for extending the uberjar profile needs to be smarter.
It seems strange that there isn't a function in Leiningen to extend profiles, but I haven't been able to find one.
Cool - thanks for the rapid response.
Can you try using "0.8.13-SNAPSHOT" and see if your problem is fixed?
It fixes the error, yes. But unfortunately it doesn't look like the profiles have been merged correctly, so the resulting uberjar is broken :-(
I've created a cut-down version of my project that demonstrates the issue:
https://github.com/paulbutcher/lein-ring-issue
With lein-ring
0.8.11, I can build and run uberjar like this:
lein cljsbuild once
lein ring uberjar
java -jar target/annotator-0.1-standalone.jar
If I then navigate to http://localhost:3000 everything's fine. I can see that the compiled ClojureScript is included in the JAR:
$ unzip -l target/annotator-0.1-standalone.jar | grep main.min.js
119332 10-12-14 14:57 public/js/main.min.js
If, on the other hand, I use lein-ring
0.8.13-SNAPSHOT, the build appears to work, but the navigating to http://localhost:3000 gives me a 404. I can see that the compiled ClojureScript is not included in the JAR:
$ unzip -l target/annotator-0.1-standalone.jar | grep main.min.js
So it looks as though the custom resource-paths
defined in the :production
profile aren't making it to the merged :uberjar
profile?
This is significantly more difficult than it should be. All we're trying to do is override a single key that Leiningen sets by default. There has to be an easier way than manually trying to reverse Leiningen's profile syntax.
I'll check on the Leiningen mailing list, see if they have any ideas.
I've asked on the mailing list and done some more experiments. This might be a bug in Leiningen, since for some reason:
:uberjar {:aot :all}
Is different to:
:foo {}
:uberjar [:foo {:aot :all}]
I had assumed they were the same, but it looks like they're not.
Ah - sounds like progress. Forgive the silly question, but on which mailing list is this conversation taking place? I can't see it in the Librelist archive:
Odd... Does the archive take a while to update? That's where I've posted to.
I guess it must :) Probably a good incentive for me to actually subscribe...
it's visible now:
http://librelist.com/browser//leiningen/2014/10/12/injecting-files-into-jars-via-plugin/
Not sure what the answer is, mind...
It looks like this is at least partially caused, or at least complicated, by https://github.com/technomancy/leiningen/issues/1694, which is fixed in Lein master, but affects version 2.5.0.
For the time being, it looks like composite profiles for uberjars don't work well.
While we're playing in this space, could a fix for this also be (or help with) a fix for https://github.com/weavejester/lein-ring/issues/116?
That seems like an entirely unrelated bug.
I've just upgraded a project from
lein-ring
0.8.11 to 0.8.12. Now, when runninglein ring uberjar
, I get:I see the same behaviour with both Leiningen 2.4.3 and 2.5.0, both locally and when building on Travis. Downgrading to
lein-ring
0.8.11 fixes the problem. Seems to be related to https://github.com/weavejester/lein-ring/commit/4acd3170429f8a42f3aa4f7fa90769af2950e01c?