Skip to content
Snippets Groups Projects
Unverified Commit 38322c37 authored by Cam Saul's avatar Cam Saul Committed by GitHub
Browse files

Merge pull request #9657 from metabase/merge-32

Merge 32
parents 0829dc7a 3174bea5
Branches
Tags
No related merge requests found
......@@ -103,8 +103,16 @@
(trs "spark-deps.jar is no longer needed by Metabase 1.0+. You can delete it from the plugins directory.")))))]
path))
(defn- has-manifest? ^Boolean [^Path path]
(boolean (files/file-exists-in-archive? path "metabase-plugin.yaml")))
(defn- init-plugins! [paths]
(doseq [^Path path paths]
;; sort paths so that ones that correspond to JARs with no plugin manifest (e.g. a dependency like the Oracle JDBC
;; driver `ojdbc8.jar`) always get initialized (i.e., added to the classpath) first; that way, Metabase drivers that
;; depend on them (such as Oracle) can be initialized the first time we see them.
;;
;; In Clojure world at least `false` < `true` so we can use `sort-by` to get non-Metabase-plugin JARs in front
(doseq [^Path path (sort-by has-manifest? paths)]
(try
(init-plugin! path)
(catch Throwable e
......
......@@ -122,6 +122,13 @@
;;; | JAR FILE CONTENTS |
;;; +----------------------------------------------------------------------------------------------------------------+
(defn file-exists-in-archive?
"True is a file exists in an archive."
[^Path archive-path & path-components]
(with-open [fs (FileSystems/newFileSystem archive-path (ClassLoader/getSystemClassLoader))]
(let [file-path (apply get-path-in-filesystem fs path-components)]
(exists? file-path))))
(defn slurp-file-from-archive
"Read the entire contents of a file from a archive (such as a JAR)."
[^Path archive-path & path-components]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment