Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Load an internal descriptor if present [IMMUTANT-212]

This still needs docs.
  • Loading branch information...
commit a894072ddc33e3623b99b0886b6870fa45563a80 1 parent b1b86df
@tobias tobias authored
View
5 docs/src/org/deployment.org
@@ -72,7 +72,7 @@
=target/native=, =classes=, and =target/classes= dirs, as well as
the =project.clj=.
- The archive process honors the =:library-path=, =:source-path(s)=, =:resources-path(s)=
+ The archive process honors the =:source-paths=, =:resources-paths=
=:native-path=, and =:compile-path= options of =project.clj=, allowing you to
override the default directories.
@@ -88,8 +88,7 @@
$ lein immutant deploy --archive path/to/project
#+end_src
- If no =.ima= archive exists in the current working directory, it will be generated
- before being deployed.
+ A new =.ima= archive will be generated each time deploy is invoked.
In addition to deploying an =.ima= directly, you can also manually deploy a
deployment descriptor that refers to the location of the archive. See the
View
11 integration-tests/src/test/clojure/immutant/integs.clj
@@ -109,16 +109,19 @@
(string/split value #",")))))
(defn generate-archives [dest-dir & app-dirs]
- (doseq [app app-dirs]
- (println "Generating archive for" app)
+ (doseq [[app opts] app-dirs]
+ (println "Generating archive for" app opts)
(archive/create (project/read (str app "/project.clj"))
(io/file app)
(io/file dest-dir)
- {})))
+ opts)))
(let [integs (io/file (.getParentFile (io/file *file*)) "integs")
namespaces (or (ns-from-property) (find-namespaces-in-dir integs))]
- (generate-archives "target/apps" "apps/ring/basic-ring")
+ (generate-archives "target/apps"
+ ["apps/ring/basic-ring"]
+ ["apps/ring/basic-ring" {:name "basic-ring-id"
+ :context-path "/basic-id"}])
(println "\nTesting namespaces:" namespaces)
(when-not *compile-files*
(let [results (atom [])
View
29 integration-tests/src/test/clojure/immutant/integs/basic_archive_with_internal_descriptor.clj
@@ -0,0 +1,29 @@
+;; Copyright 2008-2013 Red Hat, Inc, and individual contributors.
+;;
+;; This is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU Lesser General Public License as
+;; published by the Free Software Foundation; either version 2.1 of
+;; the License, or (at your option) any later version.
+;;
+;; This software is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; Lesser General Public License for more details.
+;;
+;; You should have received a copy of the GNU Lesser General Public
+;; License along with this software; if not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+
+(ns immutant.integs.basic-archive-with-internal-descriptor
+ (:use fntest.core
+ clojure.test
+ [immutant.integs.integ-helper :only [get-as-data]])
+ (:require [clojure.java.io :as io]))
+
+(use-fixtures :once (with-deployment "basic-ring-id.ima"
+ (io/file (System/getProperty "user.dir") "target/apps/basic-ring-id.ima")))
+
+(deftest simple "it should work"
+ (is (= :basic-ring (:app (get-as-data "/basic-id")))))
+
View
20 modules/bootstrap/src/main/clojure/immutant/runtime/bootstrap.clj
@@ -66,14 +66,18 @@
(vary-meta #(update-in % [:without-profiles] strip-reduce-metadata))))))
(defn ^{:internal true} read-full-app-config
- "Returns the full configuration for an app. This consists of the :immutant map
-from project.clj (if any) with the contents of the descriptor map merged onto it (if any). Returns
-nil if neither are available."
- [descriptor-file app-root]
- (let [from-descriptor (and descriptor-file
- (read-descriptor descriptor-file))
- from-project (:immutant (read-project app-root (:lein-profiles from-descriptor)))]
- (merge {} from-project from-descriptor)))
+ "Returns the full configuration for an app. This consists of
+the :immutant map from project.clj (if any) with the contents of the
+internal descriptor map merged onto it (if any) followed by the
+descriptor map (if any). Returns {} if none are available."
+[descriptor-file app-root]
+(let [external (read-descriptor descriptor-file)
+ internal (read-descriptor (io/file app-root ".immutant.clj"))
+ profiles (:lein-profiles external (:lein-profiles internal))]
+ (merge {}
+ (:immutant (read-project app-root profiles))
+ internal
+ external)))
(defn ^{:internal true} read-and-stringify-full-app-config
"Loads the full app config and stringifies the keys."
View
57 modules/bootstrap/src/test/clojure/immutant/runtime/bootstrap_test.clj
@@ -131,24 +131,49 @@
(facts "read-full-app-config"
(let [project-root (io/file (io/resource "project-root"))
non-project-root (io/file (io/resource "non-project-root"))
+ id-project-root (io/file (io/resource "id-project-root"))
+ id-non-project-root (io/file (io/resource "id-non-project-root"))
descriptor (io/file (io/resource "simple-descriptor.clj"))]
+
+ (facts "with a project"
+ (fact "should work"
+ (read-full-app-config descriptor project-root) => {:init "my.namespace/init"
+ :ham "biscuit"
+ :biscuit "gravy"
+ :resolve-dependencies false
+ :lein-profiles [:cheese]})
+
+ (fact "should work with an internal dd"
+ (read-full-app-config descriptor id-project-root) => {:init "my.namespace/init"
+ :ham "biscuit"
+ :biscuit "gravy"
+ :resolve-dependencies false
+ :lein-profiles [:biscuit :gravy]})
+ (fact "should work with no descriptor"
+ (read-full-app-config nil project-root) => {:ham "basket"
+ :biscuit "gravy"
+ :init 'some.namespace/init
+ :resolve-dependencies false
+ :lein-profiles [:cheese]})
+
+ (fact "should work with no descriptor and an internal dd"
+ (read-full-app-config nil id-project-root) => {:ham "basket"
+ :biscuit "gravy"
+ :init 'some.namespace/init
+ :resolve-dependencies false
+ :lein-profiles [:biscuit :gravy]}))
+
+ (facts "with no project"
+ (fact "should work"
+ (read-full-app-config descriptor non-project-root) => {:init "my.namespace/init"
+ :ham "biscuit"})
+
+ (fact "should work with an internal dd"
+ (read-full-app-config descriptor id-non-project-root) => {:init "my.namespace/init"
+ :ham "biscuit"
+ :lein-profiles [:biscuit :gravy]}))
- (fact "should work"
- (read-full-app-config descriptor project-root) => {:init "my.namespace/init"
- :ham "biscuit"
- :biscuit "gravy"
- :resolve-dependencies false
- :lein-profiles [:cheese]})
- (fact "should work with no project"
- (read-full-app-config descriptor non-project-root) => {:init "my.namespace/init"
- :ham "biscuit"})
-
- (fact "should work with no descriptor"
- (read-full-app-config nil project-root) => {:ham "basket"
- :biscuit "gravy"
- :init 'some.namespace/init
- :resolve-dependencies false
- :lein-profiles [:cheese]})
+
(fact "should work with no descriptor and no project"
(read-full-app-config nil non-project-root) => {}))))
View
1  modules/bootstrap/src/test/resources/id-non-project-root/.immutant.clj
@@ -0,0 +1 @@
+{:lein-profiles [:biscuit :gravy]}
View
1  modules/bootstrap/src/test/resources/id-project-root/.immutant.clj
@@ -0,0 +1 @@
+{:lein-profiles [:biscuit :gravy]}
View
12 modules/bootstrap/src/test/resources/id-project-root/project.clj
@@ -0,0 +1,12 @@
+(defproject a-project "24.32.11"
+ :dependencies [[org.clojure/clojure "1.3.0"]
+ [org.clojure/tools.logging "0.2.3"]]
+ :ham :biscuit
+ :egg :sandwich
+ :immutant {:ham "basket"
+ :biscuit "gravy"
+ :init some.namespace/init
+ :resolve-dependencies false
+ :lein-profiles [:cheese]}
+ :profiles {:gravy {:ham :not-bacon}
+ :cheese {:egg :biscuit}})
View
3  namespaces/common/src/main/clojure/immutant/runtime_util.clj
@@ -55,7 +55,8 @@
(defn ^{:internal true} read-descriptor
"Reads a deployment descriptor and returns the resulting map."
[^File file]
- (load-string (slurp (.getAbsolutePath file))))
+ (if (and file (.exists file))
+ (load-string (slurp (.getAbsolutePath file)))))
(defn ^{:internal true} read-and-stringify-descriptor
"Reads a deployment descriptor and returns the resulting stringified map."
View
2  pom.xml
@@ -379,7 +379,7 @@
<version.cheshire>5.0.1</version.cheshire>
<version.midje>1.5-alpha4</version.midje>
<version.leiningen>2.0.0</version.leiningen>
- <version.deploy-tools>0.9.2</version.deploy-tools>
+ <version.deploy-tools>0.12.0</version.deploy-tools>
<version.codox>0.6.3</version.codox>
<version.fntest>0.3.10</version.fntest>
<version.clj-http>0.5.8</version.clj-http>
Please sign in to comment.
Something went wrong with that request. Please try again.