     ; ${AMP}/module/ - note: this one is a bit unusual as it gets merged into ${AMP}/config...
     (if (fexists src-module)
       (do
-        (fs/copy-dir src-module tgt-config)
-        (.renameTo (io/file tgt-config (fname src-module)) tgt-module)))
+        (mkdir-p tgt-alfresco-module)
+        (fs/copy-dir src-module tgt-alfresco-module)
+        (.renameTo (io/file tgt-alfresco-module (fname src-module)) tgt-module)))
+
+    (if (fexists tgt-module-context)
+      (rewrite-module-context! tgt-module-context module-id))
 
     ; ${AMP}/web/
     (if (fexists src-web)


        ; Target paths (where the AMP gets constructs)
        target                 (io/file (:target-path project))
        tgt-amp                (io/file target     "amp")
        tgt-module-properties  (io/file tgt-amp    "module.properties")
        tgt-file-mapping       (io/file tgt-amp    "file-mapping.properties")
        tgt-config             (io/file tgt-amp    "config")
        tgt-lib                (io/file tgt-amp    "lib")
        tgt-licenses           (io/file tgt-amp    "licenses")
        tgt-module             (io/file tgt-config module-id)
        tgt-web                (io/file tgt-amp    "web")

        ; Output AMP file
        tgt-amp-file           (io/file target

        _                      (if (not (fexists module-properties-file))
                                 (throw (RuntimeException. (str "Invalid AMP project - " module-properties-file " is missing."))))
        module-properties      (read-module-properties project module-properties-file)
        _                      (println module-properties)
        module-id              (get module-properties "module.id")
        module-version         (get module-properties "module.version")

