Fork me on GitHub
Matthew Davidson (kingmob)16:01:43

What is the purpose of lein check? Does it catch anything that would be missed by compile or uberjar?


@kingmob compile only compiles explicit :aot classes


so if you have a project that doesn’t use :aot (typical), then you haven’t necessarily ensured all your source files can compile


also, lein check will always enable *warn-on-reflection* it seems


and lastly, lein check will try to gather up all failures in one pass I believe. so it won’t necessarily stop after one and wait for a fix there, then have to rerun it for next one, etc


since you mentioned uberjar above, it maybe the case you are using lein uberjar with something like :aot :all - which in that case the compile prep-tasks that is ran (by default) would catch most of the things lein check would - but it’s only due to you having more things happening in that profile setup in this case.


and it’s still a potentially slower way, and more step-by-step failing way, to get similar info you’d get by lein check

Matthew Davidson (kingmob)16:01:21

Thanks @mikerod. We’re calling lein check as part of our CICD process, and I’m wondering if lein check is redundant with all the later steps (compile, uberjar, etc)


if you are using uberjar + :aot :all or some sort of :aot that includes all your relevant source files you want to ensure can compile, eg :aot [], then it is somewhat redundant for those cases

🙏 4

with the exception that you won’t get *warn-on-reflection* for “free” if that matters to you


you can set :global-vars {*warn-on-reflection* true} in the project.clj as well though to get similar even without necessarily using lein check (I think it’ll be used during compile as well this way)


I like having check as a separate step, because there's information in that failure (your code isn't loadable as it sits in the repo), while uberjar has other kinds of potential failure


I have a custom version of check which also looks at test files


@kingmob for a use case example: I'm doing a big whole-project refactor and as I iterate I want to ensure I don't break the codebase, so I do one part of the change at a time, and ensure lein check passes


I don't need to make uberjars or compile classes - that's unrelated to my task


@noisesmith you can get lein check to check more ns’s by adding them to :source-paths - like in a profile


but yeah, I do like the seprate step in many situations too