Filesystem, class-file and jarjar helpers shared across the pipeline.
Two concerns live here: locating and normalizing Clojure source dirs and
files, and the Java side of inlining - finding bundled .class files and
relocating their packages via jarjar under a name+version prefix (distinct from
the namespace :project-prefix).
Filesystem, class-file and jarjar helpers shared across the pipeline. Two concerns live here: locating and normalizing Clojure source dirs and files, and the Java side of inlining - finding bundled `.class` files and relocating their packages via jarjar under a name+version prefix (distinct from the namespace `:project-prefix`).
(apply-jarjar! pname pversion srcdeps jar-file)Repackages the bundled Java .class files in jar-file in place. Relocates
every package root found under srcdeps (see java-class-dirs) beneath the
name+version prefix derived from pname/pversion, via jarjar.
Repackages the bundled Java `.class` files in `jar-file` in place. Relocates every package root found under `srcdeps` (see `java-class-dirs`) beneath the name+version prefix derived from `pname`/`pversion`, via jarjar.
(assert-no-duplicate-files files)Throw internal error if there are any duplicates in files.
Throw internal error if there are any duplicates in `files`.
(class-file->fully-qualified-name srcdeps file)Returns the fully-qualified (dotted) class name for a .class file, derived
from its path relative to srcdeps with the extension dropped.
Returns the fully-qualified (dotted) class name for a `.class` `file`, derived from its path relative to `srcdeps` with the extension dropped.
(class-files srcdeps)Returns a vector of all .class files found under the subdirectories of
srcdeps (files directly in the root are ignored).
Returns a vector of all `.class` files found under the subdirectories of `srcdeps` (files directly in the root are ignored).
(clean-name-version pname pversion)Builds an identifier-safe prefix out of pname and pversion.
Strips every non-alphanumeric character so that names or versions
containing characters like / (e.g. a version of "n/a") don't leak
into the generated package/namespace prefix and break imports.
Builds an identifier-safe prefix out of `pname` and `pversion`. Strips every non-alphanumeric character so that names or versions containing characters like `/` (e.g. a version of "n/a") don't leak into the generated package/namespace prefix and break imports.
(clj-files->dirs prefix clj-files)Returns the set of distinct directories holding clj-files, each prefixed with
prefix (as prefix/dir).
Returns the set of distinct directories holding `clj-files`, each prefixed with `prefix` (as `prefix/dir`).
(clojure-source-files dirs)Like clojure-source-files-relative, but returns each file canonicalized.
Like `clojure-source-files-relative`, but returns each file canonicalized.
(clojure-source-files-relative dirs)(clojure-source-files-relative dirs excl-dir)Returns all .clj/.cljc/.cljs files under dirs as a vector of File, left
as-is (not canonicalized). When excl-dir is given, any file under
<dir>/<excl-dir> for each of dirs is excluded.
Returns all .clj/.cljc/.cljs files under `dirs` as a vector of File, left as-is (not canonicalized). When `excl-dir` is given, any file under `<dir>/<excl-dir>` for each of `dirs` is excluded.
(determine-source-dirs {:keys [source-paths]
{:keys [included-source-paths]} :mranderson})Returns the project source dirs to inline, per the
[:mranderson :included-source-paths] option: nil/:first means just the
first source path, :source-paths means all of them, or an explicit vector of
paths is used as-is.
Returns the project source dirs to inline, per the `[:mranderson :included-source-paths]` option: `nil`/`:first` means just the first source path, `:source-paths` means all of them, or an explicit vector of paths is used as-is.
(duplicated-files files)Returns map of duplicates in files, key is fully qualified file as string, value is num occurrences.
If no duplicates, empty map is returned.
Returns map of duplicates in `files`, key is fully qualified file as string, value is num occurrences. If no duplicates, empty map is returned.
(extension->platform extension-of-moved)Returns the platform keyword for a single-platform extension: :clj for
".clj", :cljs for ".cljs". Returns nil for .cljc or anything else.
Returns the platform keyword for a single-platform extension: `:clj` for ".clj", `:cljs` for ".cljs". Returns nil for `.cljc` or anything else.
(file->extension file)Returns the Clojure source extension of file (".clj", ".cljc" or
".cljs"), or nil if it has none. Doubles as an is-this-a-source-file?
predicate.
Returns the Clojure source extension of `file` (".clj", ".cljc" or
".cljs"), or nil if it has none. Doubles as an is-this-a-source-file?
predicate.(first-src-path root source-paths)Returns the first of source-paths relative to project root (the leading
root prefix and its trailing separator are stripped).
Returns the first of `source-paths` relative to project `root` (the leading `root` prefix and its trailing separator are stripped).
(java-class-dirs srcdeps)Returns the set of top-level package roots (the first path segment under
srcdeps) that contain bundled .class files. These are the roots jarjar
relocates under the name+version prefix.
Returns the set of top-level package roots (the first path segment under `srcdeps`) that contain bundled `.class` files. These are the roots jarjar relocates under the name+version prefix.
(normalize-dirs dirs)Returns dirs (as strings) normalized, deduped and without subdirs
Returns `dirs` (as strings) normalized, deduped and without subdirs
(platform-comp platform)Returns the complementary platform keyword (:clj <-> :cljs), or nil when
platform is nil.
Returns the complementary platform keyword (`:clj` <-> `:cljs`), or nil when `platform` is nil.
(source-dep? dependency)True if dependency is marked for inlining, i.e. its metadata carries
:source-dep or :inline-dep.
True if `dependency` is marked for inlining, i.e. its metadata carries `:source-dep` or `:inline-dep`.
(srcdeps-relative srcdeps file)Returns the path of file relative to the srcdeps root, using forward
slashes. file is expected to live under srcdeps, as everything produced by
walking the srcdeps tree does.
Returns the path of `file` relative to the `srcdeps` root, using forward slashes. `file` is expected to live under `srcdeps`, as everything produced by walking the srcdeps tree does.
(sym->file-name sym)Converts a namespace symbol to its relative file path (no extension), munging dashes to underscores and dots to the platform file separator.
Converts a namespace symbol to its relative file path (no extension), munging dashes to underscores and dots to the platform file separator.
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 |