      ;;                          (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.user/gae)))
                               ;; {} (:gae (core/get-env)))))

(def web-inf-dir (str (:build-dir config-map) "/WEB-INF"))
(println "web-inf-dir: " web-inf-dir)
(println "build-dir: " (:build-dir config-map))
(def classes-dir (str web-inf-dir "/classes"))
(println "classes-dir: " classes-dir)

(defn lib-dir [] (str (:build-dir config-map) "/WEB-INF/lib"))

(def appcfg-class "com.google.appengine.tools.admin.AppCfg")


      ;; Thread.currentThread().setContextClassLoader(appengineClassloader)
      (.setContextClassLoader (Thread/currentThread) gae-class-loader))))

#_(core/deftask foo "" []
  (core/with-pre-wrap [fs]
    (println "FS: " (type fs))
    (let [asset-files (->> fs core/output-files (core/by-ext [".clj"]))]
         (doseq [asset asset-files] (println "foo" asset)))
    fs))

(core/deftask assets
  "copy assets to build-dir"
