1.2.0 permalink Arrow_down_16x16
  • (new project-name project-dir)
  • (new project-name)
Create a new project skeleton.
lein new [group-id/]artifact-id [project-dir]
Group-id is optional. Project-dir defaults to artifact-id if not given.
Neither group-id nor artifact-id may contain slashes.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source leiningen/new.clj:10 top

(defn new
  "Create a new project skeleton.
lein new [group-id/]artifact-id [project-dir]
Group-id is optional. Project-dir defaults to artifact-id if not given.
Neither group-id nor artifact-id may contain slashes."
  ([project-name project-dir]
     (when (re-find #"(?path project-ns)
             test-clj (.replace project-clj ".clj" "_test.clj")]
         (.mkdirs (file project-dir "test"))
         (.mkdirs (.getParentFile (file project-dir "src" project-clj)))
         (spit (file project-dir "src" project-clj)
               (str "(ns " project-ns ")\n"))
         (.mkdirs (.getParentFile (file project-dir "test" test-clj)))
         (spit (file project-dir "test" test-clj)
               (str "(ns " (str project-ns "-test")
                    "\n  (:use [" project-ns "] :reload-all)"
                    "\n  (:use [clojure.test]))\n\n"
                    "(deftest replace-me ;; FIXME: write\n  (is false "
                    "\"No tests have been written.\"))\n"))
         (spit (file project-dir ".gitignore")
               (join "\n" ["pom.xml" "*jar" "lib" "classes"]))
         (spit (file project-dir "README")
               (join "\n\n" [(str "# " artifact-id)
                                 "FIXME: write description"
                                 "## Usage" "FIXME: write"
                                 "## Installation" "FIXME: write"
                                 "## License" "Copyright (C) 2010 FIXME"
                                 (str "Distributed under the Eclipse Public"
                                      " License, the same as Clojure.\n")]))
         (println "Created new project in:" project-dir))))
  ([project-name] (leiningen.new/new project-name
                                     (name (symbol project-name)))))
Vars in leiningen.new/new: defn let name println re-find spit str symbol when
Used in 0 other vars

Comments top

No comments for new. Log in to add a comment.