Skip to content

Commit f8d7455

Browse files
committed
Add function to extract a map back from app.properties
This gives back an option map suitable for feeding back into build-descriptor. Used by boot-immutant to add nrepl options to an existing war.
1 parent 8fc61da commit f8d7455

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

  • src/immutant/deploy_tools
  • test/immutant/deploy_tools/test

src/immutant/deploy_tools/war.clj

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
(ns immutant.deploy-tools.war
22
(:require [clojure.string :as str]
3+
[clojure.set :as set]
34
[clojure.java.io :as io]
45
[version-clj.core :as version])
56
(:import [java.io BufferedOutputStream FileOutputStream]
7+
[java.nio.file Files FileSystems StandardOpenOption]
68
java.util.Properties
79
java.util.zip.ZipOutputStream
810
[java.util.jar JarEntry JarOutputStream]))
@@ -71,8 +73,10 @@
7173
(update-in [:classpath] (partial str/join ":"))
7274
(update-in [:classpath-jars] (partial map io/file))))
7375

74-
(defn build-descriptor [{:keys [root classpath] :as options}]
76+
(defn build-descriptor [{:keys [dev? init-fn root classpath] :as options}]
7577
(cond-> {:language "clojure"
78+
:raw-init-fn init-fn
79+
:dev? dev?
7680
:init (build-init options)}
7781
(:dev? options) (merge
7882
{:root root
@@ -85,10 +89,27 @@
8589
(defn map->properties [m]
8690
(reduce (fn [p [k v]]
8791
(doto p
88-
(.setProperty (name k) v)))
92+
(.setProperty (name k) (str v))))
8993
(Properties.)
9094
m))
9195

96+
(defn properties->partial-options-map [p]
97+
(-> (->> p
98+
(map (fn [[k v]] [(keyword k) v]))
99+
(map (fn [[k v]] [k (case k
100+
:dev? (= "true" v)
101+
:raw-init-fn (read-string v)
102+
v)]))
103+
(into {}))
104+
(select-keys [:root :classpath :dev? :raw-init-fn])
105+
(set/rename-keys {:raw-init-fn :init-fn})))
106+
107+
(defn replace-file [zip path bytes]
108+
(with-open [fs (FileSystems/newFileSystem (.toPath zip) nil)]
109+
(Files/write (.getPath fs path (make-array String 0))
110+
bytes (into-array [StandardOpenOption/CREATE])))
111+
zip)
112+
92113
(defn build-war
93114
"Creates a war file with the given entry specs.
94115

test/immutant/deploy_tools/test/war.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
(-> project insert-versions classpath))
88

99
(deftest classpath-should-include-org-immutant-wildfly-for-the-given-immutant-version
10-
(let [immutant-version "2.x.incremental.669"
10+
(let [immutant-version "2.1.3"
1111
base-project {:dependencies [['org.immutant/fntest "2.0.3"]]
1212
:dependency-resolver (partial cp/resolve-dependencies :dependencies)
1313
:dependency-hierarcher (partial cp/dependency-hierarchy :dependencies)

0 commit comments

Comments
 (0)