|
4 | 4 | (:require [clojure.string :as str] |
5 | 5 | [spdx.licenses :as sl])) |
6 | 6 |
|
7 | | -;; Initializes persistent local cache, which may take some time the first time. |
| 7 | +;; Until the SPDX library offers a cache that is built as needed, the use of |
| 8 | +;; licenses info included in the SPDX JAR should be fit for purpose because |
| 9 | +;; licenses don't change very often. |
| 10 | +(when (str/blank? (System/getProperty "org.spdx.useJARLicenseInfoOnly")) |
| 11 | + (System/setProperty "org.spdx.useJARLicenseInfoOnly" (str true))) |
| 12 | +;; Without the above the following would load all licenses from SPDX web API. |
8 | 13 | ;; Local cache is stored in the user cache directory (i.e. |
9 | 14 | ;; `${XDG_CACHE_HOME}/Spdx-Java-Library` or `${HOME}/.cache/Spdx-Java-Library`) |
10 | | -;; Normally not needed, will be lazily created, but still worth mentioning here |
11 | | -;; in case there is a need to load it at a specific time. |
12 | | -;(sl/init!) |
| 15 | +(sl/init!) |
13 | 16 |
|
14 | 17 | (defn id->license |
15 | | - "Retrieve from [SPDX](https://spdx.dev/) the full info and text of a license |
16 | | - identified with the given string `id`, or `nil` of not found. |
| 18 | + "Retrieve from [SPDX](https://spdx.dev/) library the full info and text of |
| 19 | + a license identified with the given string `id`, or `nil` if not found. |
17 | 20 | If `id` is not provided it defaults to `\"EPL-1.0\"`, a license typically |
18 | 21 | used in clojure projects. |
19 | 22 | Other popular licenses are `\"MIT\"`, `\"Apache-2.0\"`, `\"EPL-2.0\"`, or any |
|
26 | 29 | " |
27 | 30 | ([] (id->license nil)) |
28 | 31 | ([id] |
29 | | - (let [id (if (str/blank? id) "EPL-1.0" id) |
| 32 | + (let [id (if (str/blank? (str id)) "EPL-1.0" (str id)) |
30 | 33 | {:keys [id name text see-also]} |
31 | 34 | (sl/id->info id {:include-large-text-values? true}) |
32 | 35 | missing (fn [fieldname] |
|
0 commit comments