Skip to content

Commit

Permalink
Merge branch 'app'
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Jun 23, 2012
2 parents b8bebd8 + ba30d48 commit c0929c2
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.markdown
Expand Up @@ -4,7 +4,7 @@ This plugin provides the 'new' task for creating fresh project skeletons from Le

It is extensible via templates and has a simple API for creating them. With this new task, you can create templates for any sort of project scaffolding you can imagine, as simple or complex as you like.

By default, it includes three templates: default, plugin, and template. 'default' is the same as what Leiningen's old 'new' task spits out, while 'plugin' generates a skeleton Leiningen plugin project. 'template' is a very meta template for creating new templates!
By default, it includes four templates: default, app, plugin, and template. 'default' is for libraries, the same as what Leiningen's old 'new' task spits out. 'app' is for applications, while 'plugin' generates a skeleton Leiningen plugin project. 'template' is a very meta template for creating new templates.

TEMPLATES! WOOT!

Expand Down Expand Up @@ -33,11 +33,11 @@ This plugin **requires** Leiningen 1.6.2 or later. Please confirm that you have
You can pull in a newer version of this plugin than the one that comes with Leiningen 2 if you like; just add it to the `:plugins` section of your `:user` profile in ~/.lein/profiles.clj:

```clj
{:user {:plugins [[lein-newnew "0.2.6"]]}}
{:user {:plugins [[lein-newnew "0.3.4"]]}}
```

## License

Copyright © 2011-2012 Anthony Grimes
Copyright © 2011-2012 Anthony Grimes and contributors

Distributed under the Eclipse Public License, the same as Clojure.
21 changes: 21 additions & 0 deletions src/leiningen/new/app.clj
@@ -0,0 +1,21 @@
(ns leiningen.new.app
"Generate a basic application project."
(:use [leiningen.new.templates :only [renderer year project-name
->files sanitize-ns name-to-path]]))

(defn app
"An application project template."
[name]
(let [render (renderer "app")
data {:raw-name name
:name (project-name name)
:namespace (sanitize-ns name)
:nested-dirs (name-to-path name)
:year (year)}]
(println "Generating a project called" name "based on the 'app' template.")
(->files data
["project.clj" (render "project.clj" data)]
["README.md" (render "README.md" data)]
[".gitignore" (render "gitignore" data)]
["src/{{nested-dirs}}/core.clj" (render "core.clj" data)]
["test/{{nested-dirs}}/core_test.clj" (render "test.clj" data)])))
35 changes: 35 additions & 0 deletions src/leiningen/new/app/README.md
@@ -0,0 +1,35 @@
# {{name}}

FIXME: description

## Installation

Download from http://example.com/FIXME.

## Usage

FIXME: explanation

$ java -jar {{name}}-0.1.0-standalone.jar [args]

## Options

FIXME: listing of options this app accepts.

## Examples

...

### Bugs

...

### Any Other Sections
### That You Think
### Might be Useful

## License

Copyright © {{year}} FIXME

Distributed under the Eclipse Public License, the same as Clojure.
7 changes: 7 additions & 0 deletions src/leiningen/new/app/core.clj
@@ -0,0 +1,7 @@
(ns {{namespace}}.core
(:gen-class))

(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))
10 changes: 10 additions & 0 deletions src/leiningen/new/app/gitignore
@@ -0,0 +1,10 @@
/target
/lib
/classes
/checkouts
pom.xml
*.jar
*.class
.lein-deps-sum
.lein-failures
.lein-plugins
7 changes: 7 additions & 0 deletions src/leiningen/new/app/project.clj
@@ -0,0 +1,7 @@
(defproject {{raw-name}} "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.3.0"]]
:main {{raw-name}}.core)
7 changes: 7 additions & 0 deletions src/leiningen/new/app/test.clj
@@ -0,0 +1,7 @@
(ns {{namespace}}.core-test
(:use clojure.test
{{name}}.core))

(deftest a-test
(testing "FIXME, I fail."
(is (= 0 1))))
9 changes: 4 additions & 5 deletions src/leiningen/new/default.clj
@@ -1,14 +1,12 @@
(ns leiningen.new.default
"Generate a basic project."
"Generate a library project."
(:use [leiningen.new.templates :only [renderer year project-name
->files sanitize-ns name-to-path]]))

(defn default
"A general project template.
"A general project template for libraries.
This template is different from most others in that it supports
creating a project with a groupId. You can do `lein new foo.bar/baz`
for example."
Accepts a group id in the project name: `lein new foo.bar/baz`"
[name]
(let [render (renderer "default")
data {:raw-name name
Expand All @@ -17,6 +15,7 @@ for example."
:nested-dirs (name-to-path name)
:year (year)}]
(println "Generating a project called" name "based on the 'default' template.")
(println "To see other templates (app, lein plugin, etc), try `lein help new`.")
(->files data
["project.clj" (render "project.clj" data)]
["README.md" (render "README.md" data)]
Expand Down
4 changes: 1 addition & 3 deletions src/leiningen/new/default/README.md
@@ -1,8 +1,6 @@
# {{name}}

I'm an app. Or maybe I'm a library? I haven't decided yet.

The choice is up to you!
A Clojure library designed to ... well, that part is up to you.

## Usage

Expand Down

0 comments on commit c0929c2

Please sign in to comment.