Fork me on GitHub
#joker
<
2019-12-16
>
oskarkv08:12:54

How do I require a library that I have written that is not in the same dir, like a utils library? Can I specify dependencies somehow?

jcburley09:12:33

This should get you started, though there might (and, if not, should) be a document or section in the Joker distribution that gives a useful overview:

user=> (doc ns-sources)
-------------------------
joker.core/ns-sources
([sources])
  Adds to the built-in variable *ns-sources* which defines how to resolve
  external dependencies.
nil
user=> (doc joker.core/*ns-sources*)
-------------------------
joker.core/*ns-sources*
  A map from namespace reg-exps to the source to load the external dependency from
nil
user=> (doc joker.core/*classpath*)
-------------------------

  A vector of the classpath elements as configured by --classpath or
  the JOKER_CLASSPATH environment variable.

  Use colon-delimited <cp> (semicolon-delimited on Windows) for source
  directories when loading libraries via :require and the like (but
  not load-file). An empty field denotes the directory containing the
  current file being loaded, with zero or more trailing components
  removed as determined by the number of "." separators in the current
  namespace; or, if no file is being loaded, the current
  directory (this is original Joker behavior); a '.' (period) by
  itself denotes solely the current directory. Defaults to the value
  of the JOKER_CLASSPATH environment variable or, if that is
  undefined, the empty string (denoting a single empty field). The
  resulting classpath is stored herein, and this variable is used (in
  lieu of command-line arguments or environment variables) for all
  pertinent subsequent operations.
nil
user=> 

oskarkv09:12:01

Thanks!

👍 4
jcburley13:12:21

After seeing various questions here about libraries, decided to take on documenting some about this, borrowing heavily from here and elsewhere: https://github.com/candid82/joker/pull/301 Feel free to comment on the PR. Hope it's useful!

thanks 4
jcburley01:12:20

This was merged a short while ago, so is now on master.