librelist archives

« back to archive

Injecting files into jars via plugin

Injecting files into jars via plugin

From:
James Reeves
Date:
2014-10-12 @ 15:01
Hi folks,

I have a plugin (Lein-Ring) that is trying to build an uberjar with one
additional file.

Prior to Leiningen 2.5, this was relatively straightforward:

    (defn custom-uberjar [project]
      (compile-extra-file project)
      (leiningen.uberjar/uberjar project))

Unfortunately the latest Leiningen builds trigger an auto-clean on uberjar,
clearing the additional file before it can be included.

As it turns out, disabling this option is rather difficult, because it's in
the uberjar profile, rather than in the project map. You can't update the
project map directly, because the profile in the metadata overrides it. If
you try to alter the profile in the metadata, you need to take into account
all the different ways a profile can be defined (vectors, maps, etc.).

Is there an easier way to do this? This seems like a straightforward task,
but I can't find a straightforward solution.

- James

Re: Injecting files into jars via plugin

From:
James Reeves
Date:
2014-10-12 @ 17:38
Apparently I also don't understand how profiles work. I had thought that:

    :foo {}
    :uberjar [:foo {:aot :all}]

Would be the same thing as:

    :uberjar {:aot :all}

But apparently not. Why are these two profile configurations not
equivalent? Is it a bug?

- James

On 12 October 2014 16:01, James Reeves <james@booleanknot.com> wrote:

> Hi folks,
>
> I have a plugin (Lein-Ring) that is trying to build an uberjar with one
> additional file.
>
> Prior to Leiningen 2.5, this was relatively straightforward:
>
>     (defn custom-uberjar [project]
>       (compile-extra-file project)
>       (leiningen.uberjar/uberjar project))
>
> Unfortunately the latest Leiningen builds trigger an auto-clean on
> uberjar, clearing the additional file before it can be included.
>
> As it turns out, disabling this option is rather difficult, because it's
> in the uberjar profile, rather than in the project map. You can't update
> the project map directly, because the profile in the metadata overrides it.
> If you try to alter the profile in the metadata, you need to take into
> account all the different ways a profile can be defined (vectors, maps,
> etc.).
>
> Is there an easier way to do this? This seems like a straightforward task,
> but I can't find a straightforward solution.
>
> - James
>

Re: Injecting files into jars via plugin

From:
James Reeves
Date:
2014-10-12 @ 19:05
Looks like the profile confusion is caused by a issue #1694
<https://github.com/technomancy/leiningen/issues/1694>.

- James

On 12 October 2014 18:38, James Reeves <james@booleanknot.com> wrote:

> Apparently I also don't understand how profiles work. I had thought that:
>
>     :foo {}
>     :uberjar [:foo {:aot :all}]
>
> Would be the same thing as:
>
>     :uberjar {:aot :all}
>
> But apparently not. Why are these two profile configurations not
> equivalent? Is it a bug?
>
> - James
>
> On 12 October 2014 16:01, James Reeves <james@booleanknot.com> wrote:
>
>> Hi folks,
>>
>> I have a plugin (Lein-Ring) that is trying to build an uberjar with one
>> additional file.
>>
>> Prior to Leiningen 2.5, this was relatively straightforward:
>>
>>     (defn custom-uberjar [project]
>>       (compile-extra-file project)
>>       (leiningen.uberjar/uberjar project))
>>
>> Unfortunately the latest Leiningen builds trigger an auto-clean on
>> uberjar, clearing the additional file before it can be included.
>>
>> As it turns out, disabling this option is rather difficult, because it's
>> in the uberjar profile, rather than in the project map. You can't update
>> the project map directly, because the profile in the metadata overrides it.
>> If you try to alter the profile in the metadata, you need to take into
>> account all the different ways a profile can be defined (vectors, maps,
>> etc.).
>>
>> Is there an easier way to do this? This seems like a straightforward
>> task, but I can't find a straightforward solution.
>>
>> - James
>>
>
>

lein repl yields inscrutable stack trace

From:
Adam Krieg
Date:
2014-10-13 @ 22:59
I’m trying to run “lein repl” and lein barfs out a stack trace that has 
nothing I can go on as it doesn’t reference any of my code:

#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know 
how to create ISeq from: java.lang.Character>
Exception in thread "main" java.lang.ClassCastException: java.lang.String 
cannot be cast to clojure.lang.Symbol, 
compiling:(/private/var/folders/f6/xgk01qx91kz6yd4skb66jnhm0000gn/T/form-init5518336004148469764.clj:1:142)
	at clojure.lang.Compiler.load(Compiler.java:7142)
	at clojure.lang.Compiler.loadFile(Compiler.java:7086)
	at clojure.main$load_script.invoke(main.clj:274)
	at clojure.main$init_opt.invoke(main.clj:279)
	at clojure.main$initialize.invoke(main.clj:307)
	at clojure.main$null_opt.invoke(main.clj:342)
	at clojure.main$main.doInvoke(main.clj:420)
	at clojure.lang.RestFn.invoke(RestFn.java:421)
	at clojure.lang.Var.invoke(Var.java:383)
	at clojure.lang.AFn.applyToHelper(AFn.java:156)
	at clojure.lang.Var.applyTo(Var.java:700)
	at clojure.main.main(main.java:37)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast 
to clojure.lang.Symbol
	at clojure.lang.RT$1.invoke(RT.java:237)
	at user$eval5.invoke(form-init5518336004148469764.clj:1)
	at clojure.lang.Compiler.eval(Compiler.java:6703)
	at clojure.lang.Compiler.eval(Compiler.java:6692)
	at clojure.lang.Compiler.eval(Compiler.java:6692)
	at clojure.lang.Compiler.load(Compiler.java:7130)
	... 11 more
Exception in thread "Thread-4" clojure.lang.ExceptionInfo: Subprocess 
failed {:exit-code 1}
	at clojure.core$ex_info.invoke(core.clj:4327)
	at leiningen.core.eval$fn__3532.invoke(eval.clj:226)
	at clojure.lang.MultiFn.invoke(MultiFn.java:231)
	at leiningen.core.eval$eval_in_project.invoke(eval.clj:326)
	at clojure.lang.AFn.applyToHelper(AFn.java:167)
	at clojure.lang.AFn.applyTo(AFn.java:151)
	at clojure.core$apply.invoke(core.clj:619)
	at leiningen.repl$server$fn__7443.invoke(repl.clj:201)
	at clojure.lang.AFn.applyToHelper(AFn.java:159)
	at clojure.lang.AFn.applyTo(AFn.java:151)
	at clojure.core$apply.invoke(core.clj:617)
	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1788)
	at clojure.lang.RestFn.invoke(RestFn.java:425)
	at clojure.lang.AFn.applyToHelper(AFn.java:163)
	at clojure.lang.RestFn.applyTo(RestFn.java:132)
	at clojure.core$apply.invoke(core.clj:621)
	at clojure.core$bound_fn_STAR_$fn__4102.doInvoke(core.clj:1810)
	at clojure.lang.RestFn.invoke(RestFn.java:397)
	at clojure.lang.AFn.run(AFn.java:24)
	at java.lang.Thread.run(Thread.java:745)


I’m sure it’s something trivial, but I see that I’m not the only one to 
run into this problem:

http://pastie.org/pastes/8400365

My project.clj looks like:

(defproject op-station "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :main "op-station.clj-web.main"
  :url "http://example.com/FIXME"
  :dependencies [[org.clojure/clojure "1.6.0"]
                 [lib-noir "0.8.4"]
                 [selmer "0.6.9"]
                 [com.taoensso/sente        "1.1.0"]
                 [ring/ring-defaults        "0.1.1"]
                 [http-kit                  "2.1.19"]
                 [ring                      "1.3.1"]
                 [fast-zip "0.4.0"]
                 [lein-cljsbuild "1.0.3"]
                 [com.stuartsierra/component  "0.2.1"]
                 [com.taoensso/timbre "3.2.1"]
                 [com.taoensso/tower "2.0.2"]
                 [org.clojure/core.async     "0.1.338.0-5c5012-alpha"]
                 [markdown-clj "0.9.47"]
                 [commons-logging/commons-logging "1.1.1"]
                 [environ "0.5.0"]
                 [reagent "0.4.2"]
                 [org.clojure/data.zip "0.1.1"]
                 [commons-lang/commons-lang "2.3"]
                 [im.chit/cronj "1.0.1"]
                 [org.clojure/clojurescript "0.0-2322"]
                 [korma "0.3.0"]
                 [yesql "0.4.0"]
                 [mysql/mysql-connector-java "5.1.6"]
                 [noir-exception "0.2.2"]]
  :jvm-opts ["-server"]
  :profiles
  {:uberjar {:aot :all}
   :production {:ring {:open-browser? false
                       :stacktraces?  false
                       :auto-reload?  false}}
   :dev {:dependencies [[ring-mock "0.1.5"]
                        [ring/ring-devel "1.3.0"]
                        [pjstadig/humane-test-output "0.6.0"]]
         :injections [(require 'pjstadig.humane-test-output)
                      (pjstadig.humane-test-output/activate!)]
         :env {:dev true}}}
  :min-lein-version "2.0.0”)



My project was working fine until I did a lein clean and now I can’t 
proceed without this error.  Has anyone else run into this?  I’m running 
lein 2.3.4.

Thanks,
Adam

Re: [leiningen] lein repl yields inscrutable stack trace

From:
Jason Ozias
Date:
2014-10-13 @ 23:09
The first thing I saw was your main class declaration.  It should be a
symbol, not a string.

:main op-station.clj-web.main  (notice no quotes)

On Mon, Oct 13, 2014 at 6:59 PM, Adam Krieg <adammkrieg@gmail.com> wrote:

> I’m trying to run “lein repl” and lein barfs out a stack trace that has
> nothing I can go on as it doesn’t reference any of my code:
>
> #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know
> how to create ISeq from: java.lang.Character>
> Exception in thread "main" java.lang.ClassCastException: java.lang.String
> cannot be cast to clojure.lang.Symbol,
> 
compiling:(/private/var/folders/f6/xgk01qx91kz6yd4skb66jnhm0000gn/T/form-init5518336004148469764.clj:1:142)
> at clojure.lang.Compiler.load(Compiler.java:7142)
> at clojure.lang.Compiler.loadFile(Compiler.java:7086)
> at clojure.main$load_script.invoke(main.clj:274)
> at clojure.main$init_opt.invoke(main.clj:279)
> at clojure.main$initialize.invoke(main.clj:307)
> at clojure.main$null_opt.invoke(main.clj:342)
> at clojure.main$main.doInvoke(main.clj:420)
> at clojure.lang.RestFn.invoke(RestFn.java:421)
> at clojure.lang.Var.invoke(Var.java:383)
> at clojure.lang.AFn.applyToHelper(AFn.java:156)
> at clojure.lang.Var.applyTo(Var.java:700)
> at clojure.main.main(main.java:37)
> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast
> to cloju re.lang.Symbol
> at clojure.lang.RT$1.invoke(RT.java:237)
> at user$eval5.invoke(form-init5518336004148469764.clj:1)
> at clojure.lang.Compiler.eval(Compiler.java:6703)
> at clojure.lang.Compiler.eval(Compiler.java:6692)
> at clojure.lang.Compiler.eval(Compiler.java:6692)
> at clojure.lang.Compiler.load(Compiler.java:7130)
> ... 11 more
> Exception in thread "Thread-4" clojure.lang.ExceptionInfo: Subprocess
> failed {:exit-code 1}
> at clojure.core$ex_info.invoke(core.clj:4327)
> at leiningen.core.eval$fn__3532.invoke(eval.clj:226)
> at clojure.lang.MultiFn.invoke(MultiFn.java:231)
>  at leiningen.core.eval$eval_in_project.invoke(eval.clj:326)
> at clojure.lang.AFn.applyToHelper(AFn.java:167)
> at clojure.lang.AFn.applyTo(AFn.java:151)
> at clojure.core$apply.invoke(core.clj:619)
> at leiningen.repl$server$fn__7443.invoke(repl.clj:201)
> at clojure.lang.AFn.applyToHelper(AFn.java:159 )
> at clojure.lang.AFn.applyTo(AFn.java:151)
> at clojure.core$apply.invoke(core.clj:617)
> at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1788)
> at clojure.lang.RestFn.invoke(RestFn.java:425)
> at clojure.lang.AFn.applyToHelper(AFn.java:163)
> at clojure.lang.RestFn.applyTo(RestFn.java:132)
> at clojure.core$apply.invoke(core.clj:621)
> at clojure.core$bound_fn_STAR_$fn__4102.doInvoke(core.clj:1810)
> at clojure.lang.RestFn.invoke(RestFn.java:397)
> at clojure.lang.AFn.run(AFn.java:24)
> at java.lang.Thread.run(Thread.java:745)
>
>
> I’m sure it’s something trivial, but I see that I’m not the only one to
> run into this problem:
>
> http://pastie.org/pastes/8400365
>
> My project.clj looks like:
>
> (defproject op-station "0.1.0-SNAPSHOT"
>   :description "FIXM E: write description"
>   :main "op-station.clj-web.main"
>   :url "http://example.com/FIXME"
>   :dependencies [[org.clojure/clojure "1.6.0"]
>                  [lib-noir "0.8.4"]
>                  [selmer "0.6.9"]
>                  [com.taoensso/ sente        "1.1.0"]
>                  [ring/ring-defaults        "0.1.1"]
>                  [http-kit                  "2.1.19"]
>                  [ring                      "1.3.1"]
>                  [fast-zip "0.4.0"]
>                  [lein-cljsbuild "1.0.3"]
>                  [com.stuartsierra/component  "0.2.1"]
>                  [com.taoensso/timbre "3.2.1"]
>                  [com.taoensso/tower "2.0.2"]
>                  [org.clojure/core.async     "0.1.338.0-5c5012-alpha"]
>   ;                [markdown-clj "0.9.47"]
>                  [commons-logging/commons-logging "1.1.1"]
>                  [environ "0.5.0"]
>                  [reagent "0.4.2"]
>                  [org.clojure/data.zip "0.1.1"]
>                  [commons-lang/commons- lang "2.3"]
>                  [im.chit/cronj "1.0.1"]
>                  [org.clojure/clojurescript "0.0-2322"]
>                  [korma "0.3.0"]
>                  [yesql "0.4.0"]
>                  [mysql/mysql-connector-java "5.1.6"]
>                  [noir-exception "0.2.2"]]
>   :jvm-opts ["-server"]
>   :profiles
>   {:uberjar {:aot :all}
>    :production {:ring {:open-browser? false
>                        :stacktraces?  false
>                     &nbs p;  :auto-reload?  false}}
>    :dev {:dependencies [[ring-mock "0.1.5"]
>                         [ring/ring-devel "1.3.0"]
>                         [pjstadig/humane-test-output "0.6.0"]]
>          :injections [(require 'pjstadig.humane-test-output)
>                       (pjstadig.humane-test-output/activa te!)]
>          :env {:dev true}}}
>   :min-lein-version "2.0.0”)
>
>
>
> My project was working fine until I did a lein clean and now I can’t
> proceed without this error.  Has anyone else run into this?  I’m running
> lein 2.3.4.
>
> Thanks,
> Adam
>

Re: [leiningen] lein repl yields inscrutable stack trace

From:
Adam Krieg
Date:
2014-10-13 @ 23:17
Thanks, Jason!  That was it!

On Oct 13, 2014, at 7:09 PM, Jason Ozias <jason.g.ozias@gmail.com> wrote:

> The first thing I saw was your main class declaration.  It should be a 
symbol, not a string.
> 
> :main op-station.clj-web.main  (notice no quotes)
> 
> On Mon, Oct 13, 2014 at 6:59 PM, Adam Krieg <adammkrieg@gmail.com> wrote:
> I’m trying to run “lein repl” and lein barfs out a stack trace that has 
nothing I can go on as it doesn’t reference any of my code:
> 
> #<IllegalArgumentException java.lang.IllegalArgumentException: Don't 
know how to create ISeq from: java.lang.Character>
> Exception in thread "main" java.lang .ClassCastException: 
java.lang.String cannot be cast to clojure.lang.Symbol, 
compiling:(/private/var/folders/f6/xgk01qx91kz6yd4skb66jnhm0000gn/T/form-init5518336004148469764.clj:1:142)
> 	at clojure.lang.Compiler.load(Compiler.java:7142)
> 	at clojure.lang.Compiler.loadFile(Compiler.java:7086)
> 	at clojure.main$load_script.invoke(main.clj:274)
> 	at clojure.main$init_opt.invoke(main.clj:279)
> 	at clojure.main$initialize.invoke(main.clj:307)
> 	at clojure.main$null_opt.invoke(main.clj:342)
> 	at clojure.main$main.doInvoke(main.clj:420)
> 	at clojure.lang.RestFn.invoke(RestFn.java:421)
> 	at clojure.lang.Var.invoke(Var.java:383)
> 	at clojure.lang.AFn.applyToHelper(AFn.java:156)
> 	at clojure.lang.Var.applyTo(Var.java:700)
> 	at clojure.main.main(main.java:37)
> Caused by: java.lang.ClassCastException: java.lang.String cannot be cast
to cloju re.lang.Symbol
> 	at clojure.lang.RT$1.invoke(RT.java:237)
> 	at user$eval5.invoke(form-init5518336004148469764.clj:1)
> 	at clojure.lang.Compiler.eval(Compiler.java:6703)
> 	at clojure.lang.Compiler.eval(Compiler.java:6692)
> 	at clojure.lang.Compiler.eval(Compiler.java:6692)
> 	at clojure.lang.Compiler.load(Compiler.java:7130)
> 	... 11 more
> Exception in thread "Thread-4" clojure.lang.ExceptionInfo: Subprocess 
failed {:exit-code 1}
> 	at clojure.core$ex_info.invoke(core.clj:4327)
> 	at leiningen.core.eval$fn__3532.invoke(eval.clj:226)
> 	at clojure.lang.MultiFn.invoke(MultiFn.java:231)
> at leiningen.core.eval$eval_in_project.invoke(eval.clj:326)
> 	at clojure.lang.AFn.applyToHelper(AFn.java:167)
> 	at clojure.lang.AFn.applyTo(AFn.java:151)
> 	at clojure.core$apply.invoke(core.clj:619)
> 	at leiningen.repl$server$fn__7443.invoke(repl.clj:201)
> 	at clojure.lang.AFn.applyToHelper(AFn.java:159 )
> 	at clojure.lang.AFn.applyTo(AFn.java:151)
> 	at clojure.core$apply.invoke(core.clj:617)
> 	at clojure.core$with_bindings_STAR_.doInvoke(core.clj:1788)
> 	at clojure.lang.RestFn.invoke(RestFn.java:425)
> 	at clojure.lang.AFn.applyToHelper(AFn.java:163)
> at clojure.lang.RestFn.applyTo(RestFn.java:132)
> 	a t clojure.core$apply.invoke(core.clj:621)
> 	at clojure.core$bound_fn_STAR_$fn__4102.doInvoke(core.clj:1810)
> 	at clojure.lang.RestFn.invoke(RestFn.java:397)
> 	at clojure.lang.AFn.run(AFn.java:24)
> 	at java.lang.Thread.run(Thread.java:745)
> 
> 
> I’m sure it’s something trivial, but I see that I’m not the only one to 
run into this problem:
> 
> http://pastie.org/pastes/8400365
> 
> My project.clj looks like:
> 
> (defproject op-station "0.1.0-SNAPSHOT"
>   :description "FIXM E: write description"
>   :main "op-station.clj-web.main"
>   :url "http://example.com/FIXME"
>   :dependencies [[org.clojure/clojure "1.6.0"]
>                  [lib-noir "0.8.4"]
>                  [selmer "0.6.9"]
>                  [com.taoensso/ sente        "1.1.0"]
>                  [ring/ring-defaults        "0.1.1"]
>                  [http-kit                  "2.1.19"]
>                  [ring                      "1.3.1"]
>                  [fast-zip "0.4.0"]
>                  [lein-cljsbuild "1.0.3"]
>                  [com.stuartsierra/component  "0.2.1"]
>                  [com.taoensso/timbre "3.2.1"]
>                  [com.taoensso/tower "2.0.2"]
>                  [org.clojure/core.async     "0.1.338.0-5c5012-alpha"]
>   ;                [markdown-clj "0.9.47"]
>                  [commons-logging/commons-logging "1.1.1"]
>                  [environ "0.5.0"]
>                  [reagent "0.4.2"]
>                  [org.clojure/data.zip "0.1.1"]
>                  [commons-lang/commons- lang "2.3"]
>                  [im.chit/cronj "1.0.1"]
>                  [org.clojure/clojurescript "0.0-2322"]
>                  [korma "0.3.0"]
>                  [yesql "0.4.0"]
>                  [mysql/mysql-connector-java "5.1.6"]
>                  [noir-exception "0.2.2"]]
>   :jvm-opts ["-server"]
>   :profiles
>   {:uberjar {:aot :all}
>    :production {:ring {:open-browser? false
>                        :stacktraces?  false
>                     &nbs p;  :auto-reload?  false}}
>    :dev {:dependencies [[ring-mock "0.1.5"]
>                         [ring/ring-devel "1.3.0"]
>                         [pjstadig/humane-test-output "0.6.0"]]
>          :injections [(require 'pjstadig.humane-test-output)
>                       (pjstadig.humane-test-output/activa te!)]
>          :env {:dev true}}}
>   :min-lein-version "2.0.0”)
> 
> 
> 
> My project was working fine until I did a lein clean and now I can’t 
proceed without this error.  Has anyone else run into this?  I’m running 
lein 2.3.4.
> 
> Thanks,
> Adam