                    [ring/ring-servlet "1.4.0"]
                    [ring/ring-defaults "0.1.5"]
                    [ns-tracker/ns-tracker "0.3.0"]
-                   ]
+                   ])
 
- ;; web.xml doco: http://docs.oracle.com/cd/E13222_01/wls/docs81/webapp/web_xml.html
- :gae {;; :build-dir "build/exploded-app"
-       ;; :sdk-root  "~/.gradle/appengine-sdk"
-       :list-tasks true
-       ;; :verbose true
-       :aot #{'migae.servlets}
-       :app-id (clojure.string/replace +project+ #"/" ".")
-       :module "foo"
-       :version (clojure.string/lower-case (clojure.string/replace +version+ #"\." "-"))
-       :display-name {:name "hello app"}
-       :descr {:text "description of this web app, for web.xml etc."}
-       :appengine {:thread-safe true
-                   ;; :public-root "/static"
-                   :system-properties {:props [{:name "myapp.maximum-message-length" :value "140"}
-                                               {:name "myapp.notify-every-n-signups" :value "1000"}
-                                               {:name"myapp.notify-url"
-                                                :value "http://www.example.com/supnotfy"}]}
-                   ;; :env-vars [{:name "FOO" :value "BAR"}]
-                   :logging {:jul {:name "java.util.logging.config.file"
-                                   :value "WEB-INF/logging.properties"}}
-                             ;; #_{:log4j {:name "java.util.logging.config.file"
-                             ;;          :value "WEB-INF/classes/log4j.properties"}}}
-                   :sessions true
-                   :ssl true
-                   :async-session-persistence {:enabled "true" :queue-name "myqueue"}
-                   :inbound-services [{:service :mail} {:service :warmup}]
-                   ;;mime: http://www.opensource.apple.com/source/JBoss/JBoss-739/jakarta-tomcat-LE-jdk14/conf/web.xml
-                   :mime-mappings [{:ext "abs" :type "audio/x-mpeg"}
-                                   {:ext "gz"  :type "application/x-gzip"}
-                                   {:ext "htm" :type "text/html"}
-                                   {:ext "html" :type "text/html"}
-                                   {:ext "svg" :type "image/svg+xml"}
-                                   {:ext "txt" :type "text/plain"}
-                                   {:ext "xml" :type "text/xml"}
-                                   {:ext "xsl" :type "text/xsl"}
-                                   {:ext "zip" :type "application/zip"}]
-                   :precompilation true
-                   :scaling {:basic {:max-instances 11 :idle-timeout "10m"
-                                     :instance-class "B2"}
-                             :manual {:instances 5
-                                     :instance-class "B2"}
-                             :automatic {:instance-class "F2"
-                                         :idle-instances {:min 5
-                                                          ;; ‘automatic’ is the default value.
-                                                          :max "automatic"}
-                                         :pending-latency {:min "30ms" :max "automatic"}
-                                         :concurrent-requests {:max 50}}}
-                   ;; :resource-files {:include [{:path "**.xml"
-                   ;;                            :expiration "4d h5"
-                   ;;                            :http-header {:name "Access-Control-Allow-Origin"
-                   ;;                                          :value "http://example.org"}}]
-                   ;;                  :exclude [{:path "feed/**.xml"}]}
-                   ;; :static-files {:include {:path "foo/**.png"
-                   ;;                          :expiration "4d h5"
-                   ;;                          :http-header {:name "Access-Control-Allow-Origin"
-                   ;;                                        :value "http://example.org"}}
-                   ;;                :exclude {:path "bar/**.zip"}}
-                   }
-       :welcome {:file "index.html"}
-       :errors [{:code 404 :url "/404.html"}] ;; use :code, or:type, e.g 'java.lang.String
-       :servlet-ns 'migae.servlets
-       :servlets [{:ns 'migae.echo  ;; = servlet-class
-                   ;; :jsp - alternative to :ns, for using java servlet pages
-                   :name "echo-servlet"
-                   :display {:name "Awesome Echo Servlet"}
-                   :desc {:text "blah blah"}
-                   :url "/echo/*"
-                   :params [{:name "greeting" :val "Hello"}]
-                   :load-on-startup {:order 3}}
+(def gae
+  ;; web.xml doco: http://docs.oracle.com/cd/E13222_01/wls/docs81/webapp/web_xml.html
+  {;; :build-dir "build/exploded-app"
+   ;; :sdk-root  "~/.gradle/appengine-sdk"
+   :list-tasks true
+   ;; :verbose true
+   :aot #{'migae.servlets}
+   :app-id (clojure.string/replace +project+ #"/" ".")
+   :module "foo"
+   :version (clojure.string/lower-case (clojure.string/replace +version+ #"\." "-"))
+   :display-name {:name "hello app"}
+   :descr {:text "description of this web app, for web.xml etc."}
+   :appengine {:thread-safe true
+               ;; :public-root "/static"
+               :system-properties {:props [{:name "myapp.maximum-message-length" :value "140"}
+                                           {:name "myapp.notify-every-n-signups" :value "1000"}
+                                           {:name"myapp.notify-url"
+                                            :value "http://www.example.com/supnotfy"}]}
+               ;; :env-vars [{:name "FOO" :value "BAR"}]
+               :logging {:jul {:name "java.util.logging.config.file"
+                               :value "WEB-INF/logging.properties"}}
+               ;; #_{:log4j {:name "java.util.logging.config.file"
+               ;;          :value "WEB-INF/classes/log4j.properties"}}}
+               :sessions true
+               :ssl true
+               :async-session-persistence {:enabled "true" :queue-name "myqueue"}
+               :inbound-services [{:service :mail} {:service :warmup}]
+               ;;mime: http://www.opensource.apple.com/source/JBoss/JBoss-739/jakarta-tomcat-LE-jdk14/conf/web.xml
+               :mime-mappings [{:ext "abs" :type "audio/x-mpeg"}
+                               {:ext "gz"  :type "application/x-gzip"}
+                               {:ext "htm" :type "text/html"}
+                               {:ext "html" :type "text/html"}
+                               {:ext "svg" :type "image/svg+xml"}
+                               {:ext "txt" :type "text/plain"}
+                               {:ext "xml" :type "text/xml"}
+                               {:ext "xsl" :type "text/xsl"}
+                               {:ext "zip" :type "application/zip"}]
+               :precompilation true
+               :scaling {:basic {:max-instances 11 :idle-timeout "10m"
+                                 :instance-class "B2"}
+                         :manual {:instances 5
+                                  :instance-class "B2"}
+                         :automatic {:instance-class "F2"
+                                     :idle-instances {:min 5
+                                                      ;; ‘automatic’ is the default value.
+                                                      :max "automatic"}
+                                     :pending-latency {:min "30ms" :max "automatic"}
+                                     :concurrent-requests {:max 50}}}
+               ;; :resource-files {:include [{:path "**.xml"
+               ;;                            :expiration "4d h5"
+               ;;                            :http-header {:name "Access-Control-Allow-Origin"
+               ;;                                          :value "http://example.org"}}]
+               ;;                  :exclude [{:path "feed/**.xml"}]}
+               ;; :static-files {:include {:path "foo/**.png"
+               ;;                          :expiration "4d h5"
+               ;;                          :http-header {:name "Access-Control-Allow-Origin"
+               ;;                                        :value "http://example.org"}}
+               ;;                :exclude {:path "bar/**.zip"}}
+               }
+   :welcome {:file "index.html"}
+   :errors [{:code 404 :url "/404.html"}] ;; use :code, or:type, e.g 'java.lang.String
+   :servlet-ns 'migae.servlets
+   :servlets [{:ns 'migae.echo  ;; = servlet-class
+               ;; :jsp - alternative to :ns, for using java servlet pages
+               :name "echo-servlet"
+               :display {:name "Awesome Echo Servlet"}
+               :desc {:text "blah blah"}
+               :url "/echo/*"
+               :params [{:name "greeting" :val "Hello"}]
+               :load-on-startup {:order 3}}
 
-                  {:ns 'migae.math      ;; REQUIRED
-                   :name "math-servlet"  ;; REQUIRED
-                   :url "/math/*"      ;; REQUIRED
-                   :params [{:name "op" :val "+"}
-                            {:name "arg1" :val 3}
-                            {:name "arg2" :val 2}]}]
-       :appstats {:admin-console {:url "/appstats" :name "Appstats"}
-                  :name "appstats"
-                  :desc {:text "Google Appstats Service"}
-                  :url "/admin/appstats/*"
-                  :security-role "admin"
-                  :filter {:display {:name "Google Appstats"}
-                           :desc {:text "Google Appstats Filter"}
-                           :url "/*"
-                           :params [{:name "logMessage"
-                                     :val "Appstats available: /appstats/details?time={ID}"}
-                                    {:name "calculateRpcCosts"
-                                     :val true}]}
-                  :servlet {:display {:name "Google Appstats"}}}
-       :filters [{:ns 'migae.reloader   ; REQUIRED
-                  :name "reloader"      ; REQUIRED
-                  :display {:name "Clojure reload filter"} ; OPTIONAL
-                  :url "/*"            ; REQUIRED
-                  :desc {:text "clojure reload filter"}}]
-       :security [{:resource {:name "foo" :desc {:text "Foo resource security"}
-                              :url "/foo/*"}
-                  :role "admin"}]})
-
-(def gae)
-
-(println "GAE ns: " (var gae))
+              {:ns 'migae.math      ;; REQUIRED
+               :name "math-servlet"  ;; REQUIRED
+               :url "/math/*"      ;; REQUIRED
+               :params [{:name "op" :val "+"}
+                        {:name "arg1" :val 3}
+                        {:name "arg2" :val 2}]}]
+   :appstats {:admin-console {:url "/appstats" :name "Appstats"}
+              :name "appstats"
+              :desc {:text "Google Appstats Service"}
+              :url "/admin/appstats/*"
+              :security-role "admin"
+              :filter {:display {:name "Google Appstats"}
+                       :desc {:text "Google Appstats Filter"}
+                       :url "/*"
+                       :params [{:name "logMessage"
+                                 :val "Appstats available: /appstats/details?time={ID}"}
+                                {:name "calculateRpcCosts"
+                                 :val true}]}
+              :servlet {:display {:name "Google Appstats"}}}
+   :filters [{:ns 'migae.reloader   ; REQUIRED
+              :name "reloader"      ; REQUIRED
+              :display {:name "Clojure reload filter"} ; OPTIONAL
+              :url "/*"            ; REQUIRED
+              :desc {:text "clojure reload filter"}}]
+   :security [{:resource {:name "foo" :desc {:text "Foo resource security"}
+                          :url "/foo/*"}
+               :role "admin"}]})
 
 (require '[migae.boot-gae :as gae]
-         '[boot-miraj :as mrj])
+         '[boot-miraj :as mrj]
+         '[boot.task.built-in :as builtin])
 
 (task-options!
  mrj/config {:root "build/exploded-app"

                "maven-central" "http://mvnrepository.com"
                "central" "http://repo1.maven.org/maven2/"}
 :dependencies   '[[org.clojure/clojure "1.8.0" :scope "provided"]
                   [migae/boot-gae "0.1.0-SNAPSHOT" :scope "test"]
                   [miraj/boot-miraj "0.1.0-SNAPSHOT" :scope "test"]
                   [miraj/html "5.1.0-SNAPSHOT"]

       :description "Example code, boot, miraj, GAE"
       :license     {"EPL" "http://www.eclipse.org/legal/epl-v10.html"}})

(deftask libs
  "" []
  (comp
   (builtin/uber :as-jars true)
   (builtin/sift :include #{#"jar$"} :move {#"(.*jar$)" "WEB-INF/lib/$1"})
   (builtin/target :dir #{"build"} :no-clean true)))

(deftask dev
  "run all the boot-gae tasks"
  []
  (comp (gae/assets :type :html)
        (gae/assets :type :css)
        (gae/assets :type :js)
        (gae/assets :type :ico)
        (gae/assets :type :clj :odir "WEB-INF/classes")
        (gae/logging)
        (gae/config)
        (builtin/target :dir #{"build"})
        (gae/servlets) ;; :namespace 'migae.servlets)  ;; :dir "WEB-INF/classes")
        (builtin/sift :include #{#"class$"}
                      :move {#"(.*class$)" "WEB-INF/classes/$1"})
        (builtin/target :dir #{"build"} :no-clean true)
        #_(gae/run)))
