depstar
shells out to run the AOT compilation process and that does use clojure.main
but there isn't an easy way to pass --report
to that subprocess. You can, however, pass :jvm-opts
to depstar
which will in turn pass them to that subprocess:
:jvm-opts '["-Dclojure.main.report=stderr"]'
depstar
itself will write to stdout/stderr:
(! 650)-> clojure -X:jar :jar test.jar :main-class foo.bar :aot true
[main] WARN hf.depstar.uberjar - :aot is not recommended for a 'thin' JAR!
[main] INFO hf.depstar.uberjar - Compiling foo.bar ...
Execution error (FileNotFoundException) at user/eval136 (REPL:1).
Could not locate foo/bar__init.class, foo/bar.clj or foo/bar.cljc on classpath.
Full report at:
/var/folders/p1/30gnjddx6p193frh670pl8nh0000gn/T/clojure-13601013524882075105.edn
[main] ERROR hf.depstar.uberjar - Compilation of foo.bar failed!
[main] ERROR hf.depstar.uberjar - AOT FAILED
Here's the same thing with that JVM option supplied:
(! 652)-> clojure -X:jar :jar test.jar :main-class foo.bar :aot true :jvm-opts '["-Dclojure.main.report=stderr"]'
[main] WARN hf.depstar.uberjar - :aot is not recommended for a 'thin' JAR!
[main] INFO hf.depstar.uberjar - Compiling foo.bar ...
{:clojure.main/message
"Execution error (FileNotFoundException) at user/eval136 (REPL:1).\nCould not locate foo/bar__init.class, foo/bar.clj or foo/bar.cljc on classpath.\n",
:clojure.main/triage
{:clojure.error/class java.io.FileNotFoundException,
:clojure.error/line 1,
:clojure.error/cause
"Could not locate foo/bar__init.class, foo/bar.clj or foo/bar.cljc on classpath.",
:clojure.error/symbol user/eval136,
:clojure.error/phase :execution},
:clojure.main/trace
{:via
[{:type java.io.FileNotFoundException,
:message
"Could not locate foo/bar__init.class, foo/bar.clj or foo/bar.cljc on classpath.",
:at [clojure.lang.RT load "RT.java" 462]}],
:trace
[[clojure.lang.RT load "RT.java" 462]
[clojure.lang.RT load "RT.java" 424]
[clojure.core$load$fn__6856 invoke "core.clj" 6115]
[clojure.core$load invokeStatic "core.clj" 6114]
[clojure.core$load doInvoke "core.clj" 6098]
[clojure.lang.RestFn invoke "RestFn.java" 408]
[clojure.core$load_one invokeStatic "core.clj" 5897]
[clojure.core$compile$fn__6861 invoke "core.clj" 6125]
[clojure.core$compile invokeStatic "core.clj" 6125]
[clojure.core$compile invoke "core.clj" 6117]
[user$eval136 invokeStatic "NO_SOURCE_FILE" 1]
[user$eval136 invoke "NO_SOURCE_FILE" 1]
[clojure.lang.Compiler eval "Compiler.java" 7181]
[clojure.lang.Compiler eval "Compiler.java" 7136]
[clojure.core$eval invokeStatic "core.clj" 3202]
[clojure.main$eval_opt invokeStatic "main.clj" 488]
[clojure.main$eval_opt invoke "main.clj" 482]
[clojure.main$initialize invokeStatic "main.clj" 508]
[clojure.main$null_opt invokeStatic "main.clj" 542]
[clojure.main$null_opt invoke "main.clj" 539]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]],
:cause
"Could not locate foo/bar__init.class, foo/bar.clj or foo/bar.cljc on classpath."}}
Execution error (FileNotFoundException) at user/eval136 (REPL:1).
Could not locate foo/bar__init.class, foo/bar.clj or foo/bar.cljc on classpath.
[main] ERROR hf.depstar.uberjar - Compilation of foo.bar failed!
[main] ERROR hf.depstar.uberjar - AOT FAILED
Following on from the comments on Alex's answer:
Using -X does execute clojure.main
but only for the CLI API stub which then invokes one or more "exec functions". You can't pass --report
to it, but you can use the JVM option:
(! 667)-> cat src/thrower.clj
(ns thrower)
(defn bang [_] (throw (ex-info "foo" {})))
(! 668)-> clojure -X thrower/bang
Execution error (ExceptionInfo) at thrower/bang (thrower.clj:3).
foo
Full report at:
/var/folders/p1/30gnjddx6p193frh670pl8nh0000gn/T/clojure-248093423269602852.edn
(! 669)-> clojure -J-Dclojure.main.report=stderr -X thrower/bang
{:clojure.main/message
"Execution error (ExceptionInfo) at thrower/bang (thrower.clj:3).\nfoo\n",
:clojure.main/triage
{:clojure.error/class clojure.lang.ExceptionInfo,
:clojure.error/line 3,
:clojure.error/cause "foo",
:clojure.error/symbol thrower/bang,
:clojure.error/source "thrower.clj",
:clojure.error/phase :execution},
:clojure.main/trace
{:via
[{:type clojure.lang.ExceptionInfo,
:message "foo",
:data {},
:at [thrower$bang invokeStatic "thrower.clj" 3]}],
:trace
[[thrower$bang invokeStatic "thrower.clj" 3]
[thrower$bang invoke "thrower.clj" 3]
[clojure.lang.AFn applyToHelper "AFn.java" 154]
[clojure.lang.AFn applyTo "AFn.java" 144]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.core$apply invoke "core.clj" 662]
[clojure.run.exec$exec invokeStatic "exec.clj" 40]
[clojure.run.exec$exec doInvoke "exec.clj" 35]
[clojure.lang.RestFn invoke "RestFn.java" 423]
[clojure.run.exec$_main invokeStatic "exec.clj" 169]
[clojure.run.exec$_main doInvoke "exec.clj" 157]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.core$apply invokeStatic "core.clj" 667]
[clojure.main$main_opt invokeStatic "main.clj" 514]
[clojure.main$main_opt invoke "main.clj" 510]
[clojure.main$main invokeStatic "main.clj" 664]
[clojure.main$main doInvoke "main.clj" 616]
[clojure.lang.RestFn applyTo "RestFn.java" 137]
[clojure.lang.Var applyTo "Var.java" 705]
[clojure.main main "main.java" 40]],
:cause "foo",
:data {}}}
Execution error (ExceptionInfo) at thrower/bang (thrower.clj:3).
foo