   [d dir DIR str "output dir"
    c config-syms SYMS #{sym} "namespaced symbols bound to meta-config data"
    k keep bool "keep intermediate .clj files"
+   u unit-test bool "configure for unit testing (module = 'default')"
    v verbose bool "Print trace messages."]
   (comp
    (webxml :verbose verbose)
-   (appengine :verbose verbose)))
-
-(boot/deftask service-app
+   (appengine :unit-test unit-test :verbose verbose)))
+
+(boot/deftask config-app
   "generate xml config files for microservices app"
   [d dir DIR str "output dir"
    c config-syms SYMS #{sym} "namespaced symbols bound to meta-config data"

        odir (if dir dir web-inf-dir)]
    ;; (println "ODIR: " odir)
    (boot/with-pre-wrap fileset
      (let [boot-config-edn-fs (->> (boot/fileset-diff @prev-pre fileset)
                                boot/input-files
                                (boot/by-re [(re-pattern (str boot-config-edn "$"))]))]
            ;; (boot/by-name [boot-config-edn]))]
        (if (> (count boot-config-edn-fs) 1) (throw (Exception. "only one _boot_config.edn file allowed")))
        (if (= (count boot-config-edn-fs) 0) (throw (Exception. "_boot_config.edn file not found")))

        (let [boot-config-edn-f (first boot-config-edn-fs)
              web-xml (-> (boot/tmp-file boot-config-edn-f) slurp read-string)
              path     (boot/tmp-path boot-config-edn-f)
              in-file  (boot/tmp-file boot-config-edn-f)
              out-file (io/file workspace path)]
          (let [content (stencil/render-file
                         "migae/templates/xml.web.mustache"
                         web-xml)]
            (let [;;tmp-dir (boot/tmp-dir!)
                  xml-out-path (str odir "/web.xml")
                  xml-out-file (doto (io/file workspace xml-out-path) io/make-parents)
                  ;; reloader (doto (io/file tmp-dir "foobar.xml") io/make-parents)
                  ]
           ;; web.xml always
           ;; (if (.exists reloader)
           ;;   nop
           ;;   create empty reloader
              (if verbose (util/info "Configuring web.xml\n"))
              (spit xml-out-file content)))))
      (-> fileset (boot/add-resource workspace) boot/commit!))))



  {:servlets
   (vec (flatten (for [config (:servlets configs)]
          (let [urls (into [] (for [url (:urls config)]
                                {:path (str url)}))
                ns (if (:ns config) (:ns config) (:class config)) ]
            (merge config {:urls urls
                           :servlet {:ns ns}})))))})

(boot/deftask servlets
  "generate servlets class files"
