Classpath and class loader tools.
Classpath and class loader tools.
(add-classpath jar-or-dir)(add-classpath jar-or-dir classloader)A corollary to the deprecated add-classpath in clojure.core.
Attempt to add jar-or-dir, a string or java.io.File, to classloader.
When classloader is not provided, searches for a modifiable classloader rooted at the current thread's context classloader.
A corollary to the deprecated `add-classpath` in `clojure.core`. Attempt to add `jar-or-dir`, a string or `java.io.File`, to `classloader`. When `classloader` is not provided, searches for a modifiable classloader rooted at the current thread's context classloader.
(add-dependencies & kwargs)Resolves dependency :coordinates against Maven :repositories, then adds all
the resulting artifacts (jar files) to the current runtime via add-classpath:
(add-dependencies :classloader your-classloader
:coordinates '[[incanter "1.9.2"]]
:repositories (merge cemerick.pomegranate.aether/maven-central
{"clojars" "https://clojars.org/repo"}))
kwarg options:
:classloader - (optional, defaults to closest modifiable classloader in current thread's
hierarchy as per add-classpath)cemerick.pomegranate.aether/resolve-dependenciesReturns the dependency graph from cemerick.pomegranate.aether/resolve-dependencies.
Resolves dependency `:coordinates` against Maven `:repositories`, then adds all
the resulting artifacts (jar files) to the current runtime via [[add-classpath]]:
```Clojure
(add-dependencies :classloader your-classloader
:coordinates '[[incanter "1.9.2"]]
:repositories (merge cemerick.pomegranate.aether/maven-central
{"clojars" "https://clojars.org/repo"}))
```
kwarg options:
- `:classloader` - (optional, defaults to closest modifiable classloader in current thread's
hierarchy as per [[add-classpath]])
- Otherwise, kwargs are the same as [[cemerick.pomegranate.aether/resolve-dependencies]]
Returns the dependency graph from [[cemerick.pomegranate.aether/resolve-dependencies]].(classloader-hierarchy)(classloader-hierarchy tip)Returns a seq of class loaders, with the tip of the hierarchy first.
The tip defaults to the current thread context class loader.
Returns a seq of class loaders, with the `tip` of the hierarchy first. The `tip` defaults to the current thread context class loader.
(classloader-resources resource-name)(classloader-resources classloaders resource-name)Returns a sequence of [java.lang.ClassLoader [java.net.URL ...]] pairs
for all found resource-names on the classpath of each classloader.
If no classloaders are given, uses the classloader-hierarchy.
In this case, the first URL will in most circumstances match what
what clojure.java.io/resource returns.
Returns a sequence of `[java.lang.ClassLoader [java.net.URL ...]]` pairs for all found `resource-name`s on the classpath of each classloader. If no `classloaders` are given, uses the [[classloader-hierarchy]]. In this case, the first URL will in most circumstances match what what `clojure.java.io/resource` returns.
(get-classpath)(get-classpath classloaders)⚠️ for JDK 9+ returns an empty sequence.
Returns the effective classpath (i.e. not the value of
(System/getProperty "java.class.path") as a seq of URL strings.
Produces the classpath from all classloaders by default, or from a
collection of classloaders if provided. This allows you to easily look
at subsets of the current classloader hierarchy, e.g.:
(get-classpath (drop 2 (classloader-hierarchy)))
⚠️ for JDK 9+ returns an empty sequence. Returns the effective classpath (i.e. _not_ the value of `(System/getProperty "java.class.path")` as a seq of URL strings. Produces the classpath from all classloaders by default, or from a collection of `classloaders` if provided. This allows you to easily look at subsets of the current classloader hierarchy, e.g.: ```Clojure (get-classpath (drop 2 (classloader-hierarchy))) ```
(modifiable-classloader? cl)Returns true iff the given ClassLoader is of a type that satisfies
the dynapath.dynamic-classpath/DynamicClasspath protocol, and can
be modified.
Returns `true` iff the given `ClassLoader` is of a type that satisfies the `dynapath.dynamic-classpath/DynamicClasspath` protocol, and can be modified.
(resources resource-name)(resources classloaders resource-name)Returns a sequence of java.net.URLs on the effective classpath for specified specified resource-name.
This can be useful for finding name collisions among items on the classpath. In most
circumstances, the first of the returned sequence will be the same
as what clojure.java.io/resource returns.
Returns a sequence of `java.net.URL`s on the effective classpath for specified specified `resource-name`. This can be useful for finding name collisions among items on the classpath. In most circumstances, the first of the returned sequence will be the same as what `clojure.java.io/resource` returns.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |