So… you’d either want a way to specify additional items for the compilation classpath, or a way to exclude JAR files (currently the regex-based exclude operates only at the file level, not on the JAR or its contents)…
Open an issue on the depstar
GH and I’ll have a think about it…
@seancorfield will do. Thanks for the great tool and your answer.
I suspect a reasonable way to approach it is to provide an option to specify :compile-aliases
so you can tell depstar
to calculate a different basis for AOT compilation than for the JAR building part. Then you could have a :storm
alias that adds that JAR via :extra-deps
(and you’d have to use it for developing with). But “additive” is better.
works perfectly!
thank you so much
I haven't figured out how to make cursive resolve linter dependencies from aliases. But that's ok for storm since it can't resolve a lot of things from storm.
I released it as com.github.seancorfield/depstar {:mvn/version "2.0.211"}
.
My suggestion was: add a :storm
alias that has just that storm-client
dependency — and remove it from your “normal” list of dependencies. Then you use that alias (along with whatever you normally use) for dev/test — and if I add a :compile-aliases
option you would also pass it to that, since it’s needed for the compile part but not the main JAR-build part.
At work, we have a somewhat similar situation where we have a process that needs the standard root-level :deps
alias (as in tools.deps.alpha
) for a couple of actions but we don’t want it in the JAR version of that process, so we just specify -M:deps:other:aliases
when we run those particular actions and -M:other:aliases
when we run other stuff or build the JAR. That code doesn’t need it statically for compilation, only dynamically to run certain actions. Hence, I haven’t needed the :compile-aliases
option at work yet.
Does that help @sammerat?
And to be clear :compile-aliases
would be a new exec arg that you pass to depstar
— a variant of the existing :aliases
exec arg.
@seancorfield yeah that would work great
@sammerat A first cut of the implementation can be tested via
seancorfield/depstar {:git/url "<https://github.com/seancorfield/depstar>" :sha "39d234b9bce94ff8f51e0660f9db8bf475618e23"}
Needs tests and documentation but I figured you might be able to take it for a spin and let me know it works for you? (edited to update the SHA)@seancorfield thank you so much. I’ll report back tomorrow morning
@sammerat FYI -- once I added tests, I found a bug, so I updated the SHA above to reflect the correction.
Does anyone know about a generic OAuth client, which supports the PKCE flow (as defined in https://tools.ietf.org/html/rfc7636)? I'm not even sure what should I use as a generic OAuth client...
I forgot to search clojars. There are a few libs there which have oauth in their name.
I've also looked into specifically Xero API related libs and I found that the https://bitbucket.org/icm-consulting/clj-xero/src/develop/ project for example is using the https://github.com/eraf2135/clj-oauth fork of https://github.com/mattrepl/clj-oauth
Then there is https://github.com/r0man/oauth-clj from the prolific r0man
or https://clojars.org/oauth/oauth.two from the very official-sounding oauth
clojars org.
So my question more precisely is: which one of these libraries have you used and what was your experience like?
@onetom Sometimes I feel like the only clojure dev that uses https://github.com/spring-projects/spring-security
thanks for the extensive discussion!
thx for the link. i will probably use it to see how they named certain things, but i definitely won't unleash such a monstrous class hierarchy on my colleagues. imean, we are using clojure to avoid things like:
OAuth2AccessTokenResponseHttpMessageConverter.setTokenResponseConverter()
(i've found this on https://docs.spring.io/spring-security/site/docs/current/reference/html5/#oauth2client)
we have a ~200 LoC implementation, using http-kit
, clojure.data.json
and a hint of buddy-core
for the sake of convenience.
it's not super generic and some of the names are a bit quirky, but it's rather straightforward...
I have not even considered that Spring Security could be used effectively from Clojure :thinking_face:
@matt.wistrand Yeah, the one thing I use it for consistently is DelegatingPasswordEncoder
is there a compelling reason to use Sping Sec? leaving aside its provenance, depending on a monolithic (?) solution doesn't seem very aligned with clojure ideals.
Is there a way to profile namespace loading in Clojure and figure out which namespaces are taking the longest to load? I have a test suite that takes a minute or two just to load all the requisite namespaces before the assertions start happening, and am curious where that time is going and what code / dependencies I should try to get rid of.
the ones with the macros
what version of clojure?
this quick and dirty might be good enough
(cmd)user=> (alter-var-root #'require #(fn [& args] (println "require" args) (time (apply % args))))
#object[user$eval3$fn__4$fn__140 0x320494b6 "user$eval3$fn__4$fn__140@320494b6"]
(cmd)user=> (require 'clojure.set)
require (clojure.set)
"Elapsed time: 4.618158 msecs"
nil
(ins)user=> (require 'clojure.string)
require (clojure.string)
"Elapsed time: 0.074134 msecs"
nil
1.10.1
ah
isn't there a dynamic var that does essentially that?
somewhere around 1.10 there was a change to how user.clj is loaded, where loading code from user.clj could take a long time
(the change fixed it)
basically if you had a user.clj, and it loaded any core.async code it could take minutes
ah
IIRC there's a dynamic var to make it verbose, I didn't recall it printing timings and I am failing to recall the name
clojure.core/*loading-verbosely*
^^ or you can put :verbose flag in the first require (which sets that)
then you can usually just eyeball it
oh I didn't know that one, thanks
oh - it does print the timing, nice
oooh awesome
thanks
but the answer is: clojure.core.async
:)
clojure.tools.analyzer 😉
what prints the timing?
require prints the timing if you set *loading-verbosely*
(ins)user=> (require 'clojure.walk :verbose)
require (clojure.walk :verbose)
"Elapsed time: 0.068989 msecs"
nil
no, that's just the side effect of your alter var root
yet another alternative: use clojure.tools.namespace
topo-sort the namespaces then load them one at a time with a timer
Hi all, I am a bit stuck on this. How do I tell the compiler that I want the first arity of the following Paths/get
?
https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html
I tried: (Paths/get #^"[S" (into-array [(:path image)]))
I might have syntax error - I googled a bunch of stuff...
@richiardiandrea Only the ...
part maps to an array, so you want a String
followed by an array of String
.
oh man, that's silly 😄
of me
#^
is old school now, just ^
is preferred
@richiardiandrea you do not need the type hint
user=> (set! *warn-on-reflection* true)
true
user=> (Paths/get "/usr" (into-array ["local"]))
#object[sun.nio.fs.UnixPath 0x1a411233 "/usr/local"]
(because the signatures of Paths/get have distinct # of args)
I am basically parsing only one string though, sorry it was not clear maybe from the example
👌:skin-tone-3: that makes sense
Still haven't solved though, cause this fails
(Paths/get "/home" ^"[S" (into-array ^String []))
ah, ok found out - no type hint in into-array
(Paths/get (:path image) ^"[S" (into-array String []))
works
[S is not a valid type hint
should be [Ljava.lang.String;
also into-array
takes a class directly -- not a type hinted arg:
(into-array String [.....])
not
(into-array ^String [.....])
tbc — not saying issue individual require
commands. Do it in a doseq
.
But you can just time each require in the standard way once they’re topo-sorted.
user=> (-> (make-array String 0) class .getName)
"[Ljava.lang.String;"
1.10.1 was the fix
isn't [S an array of shorts?
user=> (type (make-array Short/TYPE 0))
[S
user=>
yup
only the primitives have single letter abbrevs
@richiardiandrea if you're interested in a library around java.nio.file which makes this stuff easier from clojure, check out https://babashka.org/fs/babashka.fs.html
Completely misread that S
here lol
https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.3.2-200
"Oh it's an S
- same as the first letter of String" 😅
thank you @ghadi
yeah just discovered that thank you
the array stuff is what bugged me most ;)
it took me 30 mins + asking here -> I have just replaced everything we mentioned above with babashka.fs
functions now 🤷
d'oh