      ;;                          (str (:build-dir config-map) "/WEB-INF"))}
      ;;                 :no-clean true))))
 
-(core/deftask config-servlets
-  "configure gae servlets"
-  [s clj bool "Save intermediate generated .clj file"
+(core/deftask config
+  "configure gae xml config files"
+  [d dir DIR str "output dir"
    v verbose bool "Print trace messages."]
-  (print-task "config-servlets" *opts*)
-  (let [content (stencil/render-file "migae/boot_gae/servlets.mustache" config-map)
-        servlet-ns (:servlet-ns config-map)]
-    (println "STENCIL: " content)
-    ;;(builtin/show :fileset true)
-    (comp
-     ;; step 1: process template, put result in new Fileset
-     (core/with-pre-wrap fileset
-       (let [tmp-dir (core/tmp-dir!)
-             out-path (str (str/replace servlet-ns #"\.|-" {"." "/" "-" "_"}) ".clj")
-             _ (println "out-path: " out-path)
-             out-file (doto (io/file tmp-dir out-path) io/make-parents)
-             ]
-         (spit out-file content)
-         (-> fileset (core/add-resource tmp-dir) core/commit!)))
-     (builtin/aot :namespace #{(:servlet-ns config-map)})
-     (builtin/sift :include (if clj #{#".*\.class"  #"\.clj$"} #{#"\.class$"}))
-     (builtin/target :dir #{classes-dir}
-                     :no-clean false)
-       #_(builtin/show :fileset true)
-       #_(core/reset-fileset fileset)
-       #_fileset)))
-
-(core/deftask config-xml
-  "configure gae xml config files"
-  [v verbose bool "Print trace messages."]
   (print-task "config" *opts*)
 
   ;; TODO: implement defaults
   (let [web-xml (stencil/render-file "migae/boot_gae/xml.web.mustache" config-map)
-        appengine-xml (stencil/render-file "migae/boot_gae/xml.appengine-web.mustache" config-map)]
+        appengine-xml (stencil/render-file "migae/boot_gae/xml.appengine-web.mustache" config-map)
+        odir (if dir dir web-inf-dir)]
     ;; (println "STENCIL: " web-xml)
     (comp
      ;; step 1: process template, put result in new Fileset
      (core/with-pre-wrap fileset
        (let [tmp-dir (core/tmp-dir!)
-             web-xml-out-path "web.xml"
+             web-xml-out-path (str odir "/web.xml")
              web-xml-out-file (doto (io/file tmp-dir web-xml-out-path) io/make-parents)
-             appengine-xml-out-path "appengine-web.xml"
+             appengine-xml-out-path (str odir "/appengine-web.xml")
              appengine-xml-out-file (doto (io/file tmp-dir appengine-xml-out-path) io/make-parents)
              ]
          (spit web-xml-out-file web-xml)
          (spit appengine-xml-out-file appengine-xml)
-         (-> (core/new-fileset) (core/add-resource tmp-dir) core/commit!)))
-
-     ;; step 3: commit new .xml
-     (builtin/target :dir #{(str (:build-dir config-map) "/WEB-INF")}
-                     :no-clean true))))
+         (-> fileset (core/add-resource tmp-dir) core/commit!))))))
+
+     ;; ;; step 3: commit new .xml
+     ;; (builtin/target :dir #{(str (:build-dir config-map) "/WEB-INF")}
+     ;;                 :no-clean true))))
 
 (core/deftask deploy
   "Installs a new version of the application onto the server, as the default version for end users."

            [boot.pod :as pod]
            [boot.core :as core]
            [boot.util :as util]
            [boot.task.built-in :as builtin]
            )
  (:import [com.google.appengine.tools KickStart]
           [java.io File]
           [java.net URL URLClassLoader]))


    ))))

(core/deftask servlets
  "aot compile master servlet file"
  [c clj bool "Save intermediate generated .clj file"
   d odir DIR str "output dir for generated class files"
   n namespace NS str "namespace to aot"
   s servleter SERVELETER str "namespace for master servlet generator"
   v verbose bool "Print trace messages."]
  (print-task "servlets" *opts*)
  (let [content (stencil/render-file "migae/boot_gae/servlets.mustache" config-map)
        servlet-ns (:servlet-ns config-map)
        regex (re-pattern (str "(" (str/replace servlet-ns #"\.|-" {"." "/" "-" "_"}) ".clj)"))
        dest (if odir odir classes-dir)
        mv-arg {regex (str dest "/$1")}
        aot-ns (symbol (str (if odir odir classes-dir)
                            "/" (str/replace (:servlet-ns config-map) #"\.|-" {"." "/" "-" "_"})))
                               ]
    ;; (println "aot-ns: " aot-ns)
    ;; (println "STENCIL: " content)
    (println "mv arg: " mv-arg)
    (comp
     ;; (builtin/sift :move mv-arg)
     ;; (builtin/show :fileset true)
     ;; Step 1: generate source .clj
     (core/with-pre-wrap fileset
       (let [tmp-dir (core/tmp-dir!)
             odir (if odir odir classes-dir)
             servlet-master (str (str/replace servlet-ns #"\.|-" {"." "/" "-" "_"}) ".clj")
             _ (println "servlet-master: " servlet-master)
             out-file (doto (io/file tmp-dir
                                     ;;(str odir "/"
                                     servlet-master ;;)
                        ) io/make-parents)
             ]
         (println "servlet-ns: " servlet-ns)
         (spit out-file content)
         (-> fileset (core/add-source tmp-dir) core/commit!)))
     ;; Step 2: compile it
     (builtin/aot :namespace #{servlet-ns}))))
;;                  :dir (if odir odir "./" )))))

     ;; (builtin/sift :include (if clj #{#".*\.class"  #"\.clj$"} #{#"\.class$"}))
     ;; (builtin/target :dir #{classes-dir}
     ;;                 :no-clean false)
     ;;   #_(builtin/show :fileset true)
     ;;   #_(core/reset-fileset fileset)
     ;;   #_fileset)))

(core/deftask stencil
  "Process stencil templates"
  [s stencil STENCIL str "Path to a stencil (mustache) template. Must be on classpath."
