Hi folks. Is it possible to update two values that are not in the same tree branch of a defproject using lein update-in? Im creating codox related settings at pipeline time to generate docs. I need to update both the :codox and the :profiles :dev :dependencies values. I tried to use multiple update-in (as seen in the code below) but I couldnt make it work.
lein update-in :codox assoc :themes "[\"rdash\"]" :metadata "{:doc/format :markdown}" \
-- update-in :profiles:dev:dependencies conj "[codox-theme-rdash \"0.1.2\"]" \
-- update-in :plugins conj "[lein-codox \"0.10.7\"]" \
-- codox
@marcocontatopro update-in is a task
To chain tasks you use do
Does that work?
Now that I say it. Thinking it doesnt
lol so simple! gonna try. it would be awesome. thank you friend!
Looks like you were doing it right. Sure it doesn’t work? Ha
im not using the single :
as the defproject root, maybe its related to that. Im going to try multiple calls with do
.
I don’t think do
was a good suggestion
It doesn’t “chain”
So I have cider/cider-nrepl
in my Lein profiles.clj just so I can quickly get a nrepl going with lein repl
in random projects that I am exploring. In my official projects though I usually throw it in my project.clj
because I think things like shadow-cljs will inject required middleware once it sees that dependency.
Can these two things conflict or will the project.clj take precedence?
@chase-lambert think you end up with both
but only one wins
I believe the last one declared wins - going through :dependencies
or :plugins
order (they are sequentials (eg. vectors))
wouldn't they see cider/cider-nrepl once it's injected by profiles.clj? that should haappen before their code runs
Good question. I am not sure. Let me go test that real quick.
Oh wait, I might have been super dumb with this question as it pertains to shadow-cljs because calling shadow-cljs watch app
has nothing to do with lein.
As in, I am not even using lein in that project. shadow-cljs calls the nrepl itself but that might not be necessarily the case always so I was still curious
using pprint for debugging both of these generate valid projects:
lein update-in :codox assoc :themes "[\"rdash\"]" :metadata "{:doc/format :markdown}" -- \
update-in :profiles:dev:dependencies conj "[codox-theme-rdash \"0.1.2\"]" -- \
codox
and
lein update-in :codox assoc :themes "[\"rdash\"]" :metadata "{:doc/format :markdown}" -- \
update-in : assoc :profiles "{:dev {:dependencies [[codox-theme-rdash \"0.1.2\"]]}}" -- \
codox
I think the problem is that im adding a new dependency, and therefore I would need to build the classpath again. Does it make sense @mikerod ?@marcocontatopro sorry, didn’t get to look at this. not familiar with the plugin and it sounds like the solution was related to how it works
if you put it in :dev
it may not have been merged in in time for when you were calling the task
:dev
profile is a default that is merged in in most tasks, bbut that’s not always true and also depends on what you are doing if profiles are merged implicitly ahead of time or not
noiice
thanks for clarifying
you certainly helped pointing that my script should work and linking that github PR 🙂
nice, yeah pprint
can be helpful in many cases
actually i dont think it makes sense, since codox does build the classpath
but its still failing with Could not find Codox theme: :rdash
"{:clojure.main/message
\"Syntax error (IllegalArgumentException) compiling at (/private/var/folders/vd/nd1wrjqx4p5bxvsx38gr9n440000gn/T/form-init1582674147706229508.clj:1:125).\
Could not find Codox theme: :rdash\
\",
:clojure.main/triage
{:clojure.error/phase :compile-syntax-check,
:clojure.error/line 1,
:clojure.error/column 125,
:clojure.error/source \"form-init1582674147706229508.clj\",
:clojure.error/path
\"/private/var/folders/vd/nd1wrjqx4p5bxvsx38gr9n440000gn/T/form-init1582674147706229508.clj\",
:clojure.error/class java.lang.IllegalArgumentException,
:clojure.error/cause \"Could not find Codox theme: :rdash\"},
:clojure.main/trace
{:via
[{:type clojure.lang.Compiler$CompilerException,
:message
\"Syntax error compiling at (/private/var/folders/vd/nd1wrjqx4p5bxvsx38gr9n440000gn/T/form-init1582674147706229508.clj:1:125).\",
:data
{:clojure.error/phase :compile-syntax-check,
:clojure.error/line 1,
:clojure.error/column 125,
:clojure.error/source
\"/private/var/folders/vd/nd1wrjqx4p5bxvsx38gr9n440000gn/T/form-init1582674147706229508.clj\"},
:at [clojure.lang.Compiler load \"Compiler.java\" 7648]}
{:type java.lang.IllegalArgumentException,
:message \"Could not find Codox theme: :rdash\",
:at
[codox.writer.html$apply_one_theme invokeStatic \"html.clj\" 499]}],
:trace
[[codox.writer.html$apply_one_theme invokeStatic \"html.clj\" 499]
[codox.writer.html$apply_one_theme invoke \"html.clj\" 496]
[clojure.lang.PersistentVector reduce \"PersistentVector.java\" 343]
[clojure.core$reduce invokeStatic \"core.clj\" 6827]
[clojure.core$reduce invoke \"core.clj\" 6810]
[codox.writer.html$apply_theme_transforms
invokeStatic
\"html.clj\"
502]
[codox.writer.html$apply_theme_transforms invoke \"html.clj\" 501]
[codox.writer.html$write_docs invokeStatic \"html.clj\" 507]
[codox.writer.html$write_docs invoke \"html.clj\" 504]
[clojure.lang.Var invoke \"Var.java\" 384]
[codox.main$generate_docs invokeStatic \"main.clj\" 125]
[codox.main$generate_docs invoke \"main.clj\" 116]
[user$eval11272 invokeStatic \"form-init1582674147706229508.clj\" 1]
[user$eval11272 invoke \"form-init1582674147706229508.clj\" 1]
[clojure.lang.Compiler eval \"Compiler.java\" 7177]
[clojure.lang.Compiler eval \"Compiler.java\" 7166]
[clojure.lang.Compiler eval \"Compiler.java\" 7167]
[clojure.lang.Compiler load \"Compiler.java\" 7636]
[clojure.lang.Compiler loadFile \"Compiler.java\" 7574]
[clojure.main$load_script invokeStatic \"main.clj\" 475]
[clojure.main$init_opt invokeStatic \"main.clj\" 477]
[clojure.main$init_opt invoke \"main.clj\" 477]
[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 find Codox theme: :rdash\",
:phase :compile-syntax-check}}
"
adding to :dependencies instead of :profiles:dev:dependencies seem to work. Good enough. But I didnt got what happened.