Skip to content

Commit e08adb3

Browse files
committed
License info now retrieved from SPDX jar file
1 parent 86152fd commit e08adb3

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/practicalli/licenses.clj

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,19 @@
44
(:require [clojure.string :as str]
55
[spdx.licenses :as sl]))
66

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.
813
;; Local cache is stored in the user cache directory (i.e.
914
;; `${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!)
1316

1417
(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.
1720
If `id` is not provided it defaults to `\"EPL-1.0\"`, a license typically
1821
used in clojure projects.
1922
Other popular licenses are `\"MIT\"`, `\"Apache-2.0\"`, `\"EPL-2.0\"`, or any
@@ -26,7 +29,7 @@
2629
"
2730
([] (id->license nil))
2831
([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))
3033
{:keys [id name text see-also]}
3134
(sl/id->info id {:include-large-text-values? true})
3235
missing (fn [fieldname]

0 commit comments

Comments
 (0)