Skip to content
Snippets Groups Projects
Commit 2247337e authored by Allen Gilliland's avatar Allen Gilliland
Browse files

Merge pull request #1064 from metabase/fix-loading-version-from-uberjar

Fix loading `version.properties` from uberjar
parents acddaf3c 568675c7
No related branches found
No related tags found
No related merge requests found
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
:short (-> (shell/sh "./version" "--short") :out s/trim)}) :short (-> (shell/sh "./version" "--short") :out s/trim)})
(defn- version-info-from-properties-file [] (defn- version-info-from-properties-file []
(with-open [reader (io/reader "resources/version.properties")] (with-open [reader (io/reader (io/resource "version.properties"))]
(let [props (java.util.Properties.)] (let [props (java.util.Properties.)]
(.load props reader) (.load props reader)
(into {} (for [[k v] props] (into {} (for [[k v] props]
......
;; -*- comment-column: 35; -*- ;; -*- comment-column: 35; -*-
(ns metabase.core (ns metabase.core
(:gen-class) (:gen-class)
(:require [clojure.string :as s] (:require [clojure.java.io :as io]
[clojure.string :as s]
[clojure.tools.logging :as log] [clojure.tools.logging :as log]
[colorize.core :as color] [colorize.core :as color]
[ring.adapter.jetty :as ring-jetty] [ring.adapter.jetty :as ring-jetty]
...@@ -160,11 +161,9 @@ ...@@ -160,11 +161,9 @@
(when-not (sample-dataset-id) (when-not (sample-dataset-id)
(try (try
(log/info "Loading sample dataset...") (log/info "Loading sample dataset...")
(let [resource (-> (Thread/currentThread) ; hunt down the sample dataset DB file inside the current JAR (let [resource (io/resource sample-dataset-filename)]
.getContextClassLoader
(.getResource sample-dataset-filename))]
(if-not resource (if-not resource
(log/error (format "Can't load sample dataset: the DB file '%s' can't be found by the ClassLoader." sample-dataset-filename)) (log/error (format "Can't load sample dataset: the DB file '%s' can't be found." sample-dataset-filename))
(let [h2-file (-> (.getPath resource) (let [h2-file (-> (.getPath resource)
(s/replace #"^file:" "zip:") ; to connect to an H2 DB inside a JAR just replace file: with zip: (s/replace #"^file:" "zip:") ; to connect to an H2 DB inside a JAR just replace file: with zip:
(s/replace #"\.mv\.db$" "") ; strip the .mv.db suffix from the path (s/replace #"\.mv\.db$" "") ; strip the .mv.db suffix from the path
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment