├── .gitignore ├── LICENSE ├── README.md ├── build.boot └── src ├── META-INF └── maven │ └── leiningen │ └── leiningen │ └── pom.properties ├── boot ├── generate │ ├── cljs_edn.clj │ ├── def.clj │ ├── defn.clj │ ├── edn.clj │ ├── file.clj │ └── ns.clj ├── new.clj ├── new │ ├── app.clj │ ├── app │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build.boot │ │ ├── core.clj │ │ ├── gitignore │ │ ├── hgignore │ │ ├── intro.md │ │ └── test.clj │ ├── default.clj │ ├── default │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build.boot │ │ ├── core.clj │ │ ├── gitignore │ │ ├── hgignore │ │ ├── intro.md │ │ └── test.clj │ ├── task.clj │ ├── task │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build.boot │ │ ├── gitignore │ │ ├── hgignore │ │ └── name.clj │ ├── template.clj │ ├── template │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── build.boot │ │ ├── foo.clj │ │ ├── gitignore │ │ ├── hgignore │ │ └── temp.clj │ └── templates.clj └── new_helpers.clj └── leiningen ├── new └── templates.clj └── release.clj /.gitignore: -------------------------------------------------------------------------------- 1 | pom.xml 2 | pom.xml.asc 3 | *jar 4 | /lib/ 5 | /classes/ 6 | /target/ 7 | /checkouts/ 8 | .lein-deps-sum 9 | .lein-repl-history 10 | .lein-plugins/ 11 | .lein-failures 12 | .nrepl-port 13 | /.nrepl-history 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Eclipse Public License - v 1.0 2 | 3 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 4 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 5 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 6 | 7 | 1. DEFINITIONS 8 | 9 | "Contribution" means: 10 | 11 | a) in the case of the initial Contributor, the initial code and documentation 12 | distributed under this Agreement, and 13 | b) in the case of each subsequent Contributor: 14 | i) changes to the Program, and 15 | ii) additions to the Program; 16 | 17 | where such changes and/or additions to the Program originate from and are 18 | distributed by that particular Contributor. A Contribution 'originates' 19 | from a Contributor if it was added to the Program by such Contributor 20 | itself or anyone acting on such Contributor's behalf. Contributions do not 21 | include additions to the Program which: (i) are separate modules of 22 | software distributed in conjunction with the Program under their own 23 | license agreement, and (ii) are not derivative works of the Program. 24 | 25 | "Contributor" means any person or entity that distributes the Program. 26 | 27 | "Licensed Patents" mean patent claims licensable by a Contributor which are 28 | necessarily infringed by the use or sale of its Contribution alone or when 29 | combined with the Program. 30 | 31 | "Program" means the Contributions distributed in accordance with this 32 | Agreement. 33 | 34 | "Recipient" means anyone who receives the Program under this Agreement, 35 | including all Contributors. 36 | 37 | 2. GRANT OF RIGHTS 38 | a) Subject to the terms of this Agreement, each Contributor hereby grants 39 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 40 | reproduce, prepare derivative works of, publicly display, publicly 41 | perform, distribute and sublicense the Contribution of such Contributor, 42 | if any, and such derivative works, in source code and object code form. 43 | b) Subject to the terms of this Agreement, each Contributor hereby grants 44 | Recipient a non-exclusive, worldwide, royalty-free patent license under 45 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 46 | transfer the Contribution of such Contributor, if any, in source code and 47 | object code form. This patent license shall apply to the combination of 48 | the Contribution and the Program if, at the time the Contribution is 49 | added by the Contributor, such addition of the Contribution causes such 50 | combination to be covered by the Licensed Patents. The patent license 51 | shall not apply to any other combinations which include the Contribution. 52 | No hardware per se is licensed hereunder. 53 | c) Recipient understands that although each Contributor grants the licenses 54 | to its Contributions set forth herein, no assurances are provided by any 55 | Contributor that the Program does not infringe the patent or other 56 | intellectual property rights of any other entity. Each Contributor 57 | disclaims any liability to Recipient for claims brought by any other 58 | entity based on infringement of intellectual property rights or 59 | otherwise. As a condition to exercising the rights and licenses granted 60 | hereunder, each Recipient hereby assumes sole responsibility to secure 61 | any other intellectual property rights needed, if any. For example, if a 62 | third party patent license is required to allow Recipient to distribute 63 | the Program, it is Recipient's responsibility to acquire that license 64 | before distributing the Program. 65 | d) Each Contributor represents that to its knowledge it has sufficient 66 | copyright rights in its Contribution, if any, to grant the copyright 67 | license set forth in this Agreement. 68 | 69 | 3. REQUIREMENTS 70 | 71 | A Contributor may choose to distribute the Program in object code form under 72 | its own license agreement, provided that: 73 | 74 | a) it complies with the terms and conditions of this Agreement; and 75 | b) its license agreement: 76 | i) effectively disclaims on behalf of all Contributors all warranties 77 | and conditions, express and implied, including warranties or 78 | conditions of title and non-infringement, and implied warranties or 79 | conditions of merchantability and fitness for a particular purpose; 80 | ii) effectively excludes on behalf of all Contributors all liability for 81 | damages, including direct, indirect, special, incidental and 82 | consequential damages, such as lost profits; 83 | iii) states that any provisions which differ from this Agreement are 84 | offered by that Contributor alone and not by any other party; and 85 | iv) states that source code for the Program is available from such 86 | Contributor, and informs licensees how to obtain it in a reasonable 87 | manner on or through a medium customarily used for software exchange. 88 | 89 | When the Program is made available in source code form: 90 | 91 | a) it must be made available under this Agreement; and 92 | b) a copy of this Agreement must be included with each copy of the Program. 93 | Contributors may not remove or alter any copyright notices contained 94 | within the Program. 95 | 96 | Each Contributor must identify itself as the originator of its Contribution, 97 | if 98 | any, in a manner that reasonably allows subsequent Recipients to identify the 99 | originator of the Contribution. 100 | 101 | 4. COMMERCIAL DISTRIBUTION 102 | 103 | Commercial distributors of software may accept certain responsibilities with 104 | respect to end users, business partners and the like. While this license is 105 | intended to facilitate the commercial use of the Program, the Contributor who 106 | includes the Program in a commercial product offering should do so in a manner 107 | which does not create potential liability for other Contributors. Therefore, 108 | if a Contributor includes the Program in a commercial product offering, such 109 | Contributor ("Commercial Contributor") hereby agrees to defend and indemnify 110 | every other Contributor ("Indemnified Contributor") against any losses, 111 | damages and costs (collectively "Losses") arising from claims, lawsuits and 112 | other legal actions brought by a third party against the Indemnified 113 | Contributor to the extent caused by the acts or omissions of such Commercial 114 | Contributor in connection with its distribution of the Program in a commercial 115 | product offering. The obligations in this section do not apply to any claims 116 | or Losses relating to any actual or alleged intellectual property 117 | infringement. In order to qualify, an Indemnified Contributor must: 118 | a) promptly notify the Commercial Contributor in writing of such claim, and 119 | b) allow the Commercial Contributor to control, and cooperate with the 120 | Commercial Contributor in, the defense and any related settlement 121 | negotiations. The Indemnified Contributor may participate in any such claim at 122 | its own expense. 123 | 124 | For example, a Contributor might include the Program in a commercial product 125 | offering, Product X. That Contributor is then a Commercial Contributor. If 126 | that Commercial Contributor then makes performance claims, or offers 127 | warranties related to Product X, those performance claims and warranties are 128 | such Commercial Contributor's responsibility alone. Under this section, the 129 | Commercial Contributor would have to defend claims against the other 130 | Contributors related to those performance claims and warranties, and if a 131 | court requires any other Contributor to pay any damages as a result, the 132 | Commercial Contributor must pay those damages. 133 | 134 | 5. NO WARRANTY 135 | 136 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN 137 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR 138 | IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, 139 | NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each 140 | Recipient is solely responsible for determining the appropriateness of using 141 | and distributing the Program and assumes all risks associated with its 142 | exercise of rights under this Agreement , including but not limited to the 143 | risks and costs of program errors, compliance with applicable laws, damage to 144 | or loss of data, programs or equipment, and unavailability or interruption of 145 | operations. 146 | 147 | 6. DISCLAIMER OF LIABILITY 148 | 149 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 150 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 151 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 152 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 153 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 154 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 155 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 156 | OF SUCH DAMAGES. 157 | 158 | 7. GENERAL 159 | 160 | If any provision of this Agreement is invalid or unenforceable under 161 | applicable law, it shall not affect the validity or enforceability of the 162 | remainder of the terms of this Agreement, and without further action by the 163 | parties hereto, such provision shall be reformed to the minimum extent 164 | necessary to make such provision valid and enforceable. 165 | 166 | If Recipient institutes patent litigation against any entity (including a 167 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 168 | (excluding combinations of the Program with other software or hardware) 169 | infringes such Recipient's patent(s), then such Recipient's rights granted 170 | under Section 2(b) shall terminate as of the date such litigation is filed. 171 | 172 | All Recipient's rights under this Agreement shall terminate if it fails to 173 | comply with any of the material terms or conditions of this Agreement and does 174 | not cure such failure in a reasonable period of time after becoming aware of 175 | such noncompliance. If all Recipient's rights under this Agreement terminate, 176 | Recipient agrees to cease use and distribution of the Program as soon as 177 | reasonably practicable. However, Recipient's obligations under this Agreement 178 | and any licenses granted by Recipient relating to the Program shall continue 179 | and survive. 180 | 181 | Everyone is permitted to copy and distribute copies of this Agreement, but in 182 | order to avoid inconsistency the Agreement is copyrighted and may only be 183 | modified in the following manner. The Agreement Steward reserves the right to 184 | publish new versions (including revisions) of this Agreement from time to 185 | time. No one other than the Agreement Steward has the right to modify this 186 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 187 | Eclipse Foundation may assign the responsibility to serve as the Agreement 188 | Steward to a suitable separate entity. Each new version of the Agreement will 189 | be given a distinguishing version number. The Program (including 190 | Contributions) may always be distributed subject to the version of the 191 | Agreement under which it was received. In addition, after a new version of the 192 | Agreement is published, Contributor may elect to distribute the Program 193 | (including its Contributions) under the new version. Except as expressly 194 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 195 | licenses to the intellectual property of any Contributor under this Agreement, 196 | whether expressly, by implication, estoppel or otherwise. All rights in the 197 | Program not expressly granted under this Agreement are reserved. 198 | 199 | This Agreement is governed by the laws of the State of New York and the 200 | intellectual property laws of the United States of America. No party to this 201 | Agreement will bring a legal action under this Agreement more than one year 202 | after the cause of action arose. Each party waives its rights to a jury trial in 203 | any resulting litigation. 204 | 205 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # boot-new 2 | 3 | A Boot task that generates projects from Leiningen templates or Boot templates. 4 | 5 | [![Clojars Project](https://img.shields.io/clojars/v/boot/new.svg)](https://clojars.org/boot/new) 6 | 7 | ## Getting Started 8 | 9 | Create a basic application: 10 | 11 | boot -d boot/new new -t app -n myapp 12 | cd myapp 13 | boot run 14 | 15 | Built-in templates are: 16 | 17 | * `app` -- A minimal Hello World! application. Comes with `build`, `run`, `test` tasks. `build` creates a runnable "uberjar" in the `target` folder. 18 | * `default` -- A minimal library. Comes with `build`, `test` tasks. `build` installs a JAR of the project into your local Maven cache so you can use `boot watch build` while you're developing to have the latest version always available to other projects. 19 | * `task` -- An example set of Boot tasks. Provides `*-pass-thru`, `*-post`, `*-pre`, `*-simple` task examples for you to build on, as well as `build`, `test` tasks. `build` works as for `default` above. 20 | * `template` -- A minimal Boot template. Provides `build`, `new`, `test` tasks. `build` works as for `default` above. `new` will create a new project based on the template itself. 21 | 22 | ## General Usage 23 | 24 | You can specify a template and a project name: 25 | 26 | boot -d boot/new new -t template-name -n project-name 27 | 28 | `boot-new` will look for `template-name/boot-template` (on Clojars and Maven Central). If it doesn't find a Boot Template (see below), it will look for `template-name/lein-template` instead. `boot-new` should be able to run any existing Leiningen template (if you find one that doesn't work, [please tell me about it](https://github.com/boot-clj/boot-new/issues)!). `boot-new` will then generate a new project folder called `project-name` containing files generated from the specified `template-name`. 29 | 30 | If the folder `project-name` already exists, `boot-new` will not overwrite it unless you specify the `-f` / `--force` option. You can override the folder name used with the `-o` / `--to-dir` option. By default, `boot-new` will look for the most recent stable release of the specified template. You can tell it to search for snapshots with the `-S` / `--snapshot` option, and you can specify a particular version to use with the `-V` / `--template-version` option. In general, the long-form option follows the naming used by Leiningen's `new` task for familiarity. 31 | 32 | You can pass arguments through to the underlying template with the `-a` / `--args` option (Leiningen uses `--` to separate template arguments from other options but Boot already parses options a little differently). 33 | 34 | For a full list of options, ask `new` for help: 35 | 36 | boot -d boot/new new -h 37 | 38 | The intent is that all of the basic options from Leiningen's `new` task are supported, along with Boot-specific versions of the built-in templates (`app`, `default`, `task` -- instead of Leiningen's `plugin`, and `template`). 39 | 40 | ## Boot Templates 41 | 42 | Boot templates are very similar to Leiningen templates but have an artifact name based on `boot-template` instead of `lein-template` and uses `boot` instead of `leiningen` in all the namespace names. In particular the `boot.new.templates` namespace provides functions such as `renderer` and `->files` that are the equivalent of the ones found in `leiningen.new.templates` when writing a Leiningen Template. The built-in templates are Boot templates, that produce Boot projects. 43 | 44 | To develop a new template, run `boot -d boot/new new -t template -n my-template`. This will generate a project whose `build.boot` has `(def project 'my-template/boot-template)`, with version `0.1.0-SNAPSHOT`. To test it, you will need to build and install it locally (the generated `build.boot` contains a `build` task for this purpose) and then use it to create a project, using either `--snapshot` or `--template-version` so `boot-new` will know which version to use. By default, it looks for the most recent non-SNAPSHOT release on clojars.org. 45 | 46 | ### Arguments 47 | 48 | Previous sections have revealed that it is possible to pass arguments to templates. For multiple arguments, use one `-a` for each argument. For example: 49 | 50 | ``` 51 | # Inside custom-template folder, relying on that template's boot new task. 52 | boot new -t custom-template -n project-name -a arg1 -a arg2 -a arg3 53 | ``` 54 | 55 | These arguments are accessible in the custom-template function as a second argument. 56 | 57 | ```clj 58 | (defn custom-template 59 | [name & args] 60 | (println name " has the following arguments: " args)) 61 | ``` 62 | 63 | ## Boot Generators 64 | 65 | Whereas Boot templates will generate an entire new project in a new directory, Boot generators are intended to add / modify code in an existing project. `boot-new` will run a generator with the `-g type` or `-g type=name` options. The `type` specifies the type of generator to use. The `name` is the main argument that is passed to the generator. 66 | 67 | A Boot generator can be part of a project or a template. A generator `foo`, has a `boot.generate.foo/generate` function that accepts at least two arguments, `prefix` and the `name` specified in the `-g` / `--generate` option (which will be `nil` if no `name` was specified -- the generator should validate that). `prefix` specifies the directory in which to perform the code generation and defaults to `src`. It can be overridden with the `-p` / `--prefix` option, but a generator is also free to simply ignore it anyway. In addition, any arguments specified by the `-a` / `--args` option are passed as additional arguments to the generator. 68 | 69 | There are currently a few built-in generators: 70 | - `file` 71 | - `ns` 72 | - `def` 73 | - `defn` 74 | - `edn` 75 | 76 | The `file` generator creates files relative to the prefix. It optionally accepts a body, file extension, and append? argument. 77 | ```bash 78 | boot -d boot/new new -g file=foo.bar -a "(ns foo.bar)" -a "clj" 79 | ``` 80 | 81 | The `ns` generator creates a clojure namespace by using the `file` generator and providing a few defaults. 82 | ```bash 83 | boot -d boot/new new -g ns=foo.bar 84 | ``` 85 | 86 | This will generate `src/foo/bar.clj` containing `(ns foo.bar)` (and a placeholder docstring). It will not replace an existing file unless you specify `-f` / `--force` (so `ns` generators are safe-by-default. 87 | ```bash 88 | boot -d boot/new new -g defn=foo.bar/my-func 89 | ``` 90 | 91 | If `src/foo/bar.clj` does not exist, it will be generated as a namespace first (using the `ns` generator above), then a definition for `my-func` will be appended to that file (with a placeholder docstring and a dummy argument vector of `[args]`). The generator does not check whether that `defn` already exists so it always appends a new `defn`. 92 | 93 | Both the `def` and `defn` generators create files using the `ns` generator above. 94 | 95 | The `edn` generator uses the `file` generator internally, with a default extension of `"edn"`. 96 | ```bash 97 | boot -d boot/new new -g edn=foo.bar -a "(ns foo.bar)" 98 | ``` 99 | 100 | ## Roadmap 101 | 102 | * Improve the built-in template `template` so that it can be used to seed a new Boot project. 103 | 104 | ## License 105 | 106 | Copyright © 2016-2018 Sean Corfield and the Leiningen Team for much of the code -- thank you! 107 | 108 | Distributed under the Eclipse Public License version 1.0. 109 | -------------------------------------------------------------------------------- /build.boot: -------------------------------------------------------------------------------- 1 | (set-env! :resource-paths #{"src"}) 2 | 3 | (def version "0.5.4") 4 | 5 | (task-options! 6 | pom {:project 'boot/new 7 | :version version 8 | :description "Generate projects from Boot templates." 9 | :url "https://github.com/boot-clj/boot-new" 10 | :scm {:url "https://github.com/boot-clj/boot-new"} 11 | :license {"Eclipse Public License" 12 | "http://www.eclipse.org/legal/epl-v10.html"}}) 13 | 14 | (deftask build [] 15 | (comp (pom) (jar) (install))) 16 | 17 | (deftask deploy 18 | [] 19 | (comp (pom) (jar) (push))) 20 | -------------------------------------------------------------------------------- /src/META-INF/maven/leiningen/leiningen/pom.properties: -------------------------------------------------------------------------------- 1 | version=2.6.1 2 | -------------------------------------------------------------------------------- /src/boot/generate/cljs_edn.clj: -------------------------------------------------------------------------------- 1 | (ns boot.generate.cljs-edn 2 | (:require [boot.generate.edn :as gen-edn] 3 | [boot.new.templates :as tmpl] 4 | [clojure.java.io :as io] 5 | [clojure.string :as str])) 6 | 7 | (defn generate 8 | "Append the specified definition to the specified namespace. 9 | Create the namespace if necessary. The symbol should be 10 | fully-qualified: my.ns/my-var" 11 | [prefix name & [require init-fns compiler-options]] 12 | (let [[fs-name the-sym] (str/split name #"/") 13 | path (tmpl/name-to-path ns-name) 14 | ext "cljs.edn" 15 | edn-file (io/file (str prefix "/" path "." ext))] 16 | (when-not (.exists edn-file) 17 | (gen-edn/generate prefix fs-name 18 | (str "\n{:require " require 19 | "\n :init-fns " init-fns 20 | "\n :compiler-options " compiler-options "}\n") 21 | ext)))) 22 | -------------------------------------------------------------------------------- /src/boot/generate/def.clj: -------------------------------------------------------------------------------- 1 | (ns boot.generate.def 2 | (:require [boot.generate.ns :as gen-ns] 3 | [boot.new.templates :as tmpl] 4 | [clojure.java.io :as io] 5 | [clojure.string :as str])) 6 | 7 | (defn generate 8 | "Append the specified definition to the specified namespace. 9 | Create the namespace if necessary. The symbol should be 10 | fully-qualified: my.ns/my-var" 11 | [prefix name & [body]] 12 | (let [[ns-name the-sym] (str/split name #"/") 13 | path (tmpl/name-to-path ns-name) 14 | ext "clj" 15 | ns-file (io/file (str prefix "/" path "." ext))] 16 | (when-not (.exists ns-file) 17 | (gen-ns/generate prefix ns-name)) 18 | (gen-file/generate prefix ns-name 19 | (str "\n(def " the-sym 20 | "\n \"Generated by Boot\"" 21 | "\n "body")\n") 22 | ext 23 | true))) 24 | -------------------------------------------------------------------------------- /src/boot/generate/defn.clj: -------------------------------------------------------------------------------- 1 | (ns boot.generate.defn 2 | (:require [boot.generate.file :as gen-file] 3 | [boot.generate.ns :as gen-ns] 4 | [boot.new.templates :as tmpl] 5 | [clojure.java.io :as io] 6 | [clojure.string :as str])) 7 | 8 | (defn generate 9 | "Append the specified function to the specified namespace. 10 | Create the namespace if necessary. The fn-name should be 11 | fully-qualified: my.ns/my-func" 12 | [prefix fn-name] 13 | (let [[ns-name the-fn] (str/split fn-name #"/") 14 | path (tmpl/name-to-path ns-name) 15 | ext "clj" 16 | ns-file (io/file (str prefix "/" path "." ext))] 17 | (when-not (.exists ns-file) 18 | (gen-ns/generate prefix ns-name)) 19 | (gen-file/generate prefix ns-name 20 | (str "\n(defn " the-fn 21 | "\n \"Generated by Boot\"" 22 | "\n [args]" 23 | "\n (println \"WRITEME\"))\n") 24 | ext 25 | true))) 26 | -------------------------------------------------------------------------------- /src/boot/generate/edn.clj: -------------------------------------------------------------------------------- 1 | (ns boot.generate.edn 2 | (:require [boot.generate.file :as gen-file] 3 | [boot.new.templates :as tmpl])) 4 | 5 | (defn generate 6 | "Generate a new edn file relative to the prefix." 7 | [prefix ns-name & [body ext]] 8 | (gen-file/generate prefix ns-name (str body) (or ext "edn"))) 9 | -------------------------------------------------------------------------------- /src/boot/generate/file.clj: -------------------------------------------------------------------------------- 1 | (ns boot.generate.file 2 | (:require [boot.generate.file :as gen-file] 3 | [boot.new.templates :as tmpl])) 4 | 5 | (defn generate 6 | "Generate a new file relative to the prefix." 7 | [prefix fs-name & [body ext append?]] 8 | (tmpl/->files {:prefix prefix :path (tmpl/name-to-path fs-name) :ext (or ext "clj")} 9 | ["{{prefix}}/{{path}}.{{ext}}" (str body) :append (or append? false)])) 10 | -------------------------------------------------------------------------------- /src/boot/generate/ns.clj: -------------------------------------------------------------------------------- 1 | (ns boot.generate.ns 2 | (:require [boot.new.templates :as tmpl])) 3 | 4 | (defn generate 5 | "Generate a new namespace relative to the prefix." 6 | [prefix ns-name] 7 | (gen-file/generate prefix ns-name (str "(ns " ns-name "\n \"Generated by Boot\")\n"))) 8 | -------------------------------------------------------------------------------- /src/boot/new.clj: -------------------------------------------------------------------------------- 1 | (ns boot.new 2 | "Generate project scaffolding based on a template. 3 | Adapted from leiningen.new, with permission of the Leiningen team." 4 | {:boot/export-tasks true} 5 | (:refer-clojure :exclude [new]) 6 | (:require [boot.core :as core] 7 | [boot.util :as util])) 8 | 9 | (core/deftask new 10 | "Generate a new project from a template 11 | 12 | The long form arguments mostly follow those of `lein new` except that -n / --name 13 | is required and you specify the template with -t / --template." 14 | [a args ARG [str] "arguments for the template itself." 15 | f force bool "Force Boot new to overwrite existing directory." 16 | g generate SPEC [str] "things to generate" 17 | n name NAME str "generated project name" 18 | o to-dir DIR str "directory to use instead of NAME" 19 | p prefix PATH str "source directory prefix for generate (src)" 20 | s show bool "Show documentation for the template." 21 | S snapshot bool "Look for a SNAPSHOT version of the template." 22 | t template TEMPLATE str "the template to use" 23 | V template-version VER str "the version of the template to use" 24 | v verbose int "Be increasingly verbose."] 25 | 26 | ;; suppress target warning since it makes no sense for boot-new 27 | (System/setProperty "BOOT_EMIT_TARGET" "no") 28 | (core/merge-env! :dependencies '[[stencil "0.5.0" :exclusions [org.clojure/clojure]]]) 29 | 30 | (core/with-pass-thru fs 31 | (require '[boot.new-helpers :as helpers]) 32 | (cond (and show (not template)) 33 | (util/exit-error (println "Template name is required (-t, --template) for show option (-s, --show).")) 34 | 35 | show 36 | ((resolve 'helpers/template-show) template) 37 | 38 | generate 39 | ((resolve 'helpers/generate-code) *opts*) 40 | 41 | (not name) 42 | (throw (ex-info "Project name is required (-n, --name)." {})) 43 | 44 | :else ((resolve 'helpers/create) *opts*)))) 45 | -------------------------------------------------------------------------------- /src/boot/new/app.clj: -------------------------------------------------------------------------------- 1 | (ns boot.new.app 2 | "Generate a basic application project." 3 | (:require [boot.new.templates :refer [renderer year date project-name 4 | ->files sanitize-ns name-to-path 5 | multi-segment]])) 6 | 7 | (defn app 8 | "An application project template." 9 | [name] 10 | (let [render (renderer "app") 11 | main-ns (multi-segment (sanitize-ns name)) 12 | data {:raw-name name 13 | :name (project-name name) 14 | :namespace main-ns 15 | :nested-dirs (name-to-path main-ns) 16 | :year (year) 17 | :date (date)}] 18 | (println "Generating a project called" name "based on the 'app' template.") 19 | (->files data 20 | ["build.boot" (render "build.boot" data)] 21 | ["README.md" (render "README.md" data)] 22 | ["doc/intro.md" (render "intro.md" data)] 23 | [".gitignore" (render "gitignore" data)] 24 | [".hgignore" (render "hgignore" data)] 25 | ["src/{{nested-dirs}}.clj" (render "core.clj" data)] 26 | ["test/{{nested-dirs}}_test.clj" (render "test.clj" data)] 27 | ["LICENSE" (render "LICENSE" data)] 28 | ["CHANGELOG.md" (render "CHANGELOG.md" data)] 29 | "resources/.keep" ""))) 30 | -------------------------------------------------------------------------------- /src/boot/new/app/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - {{date}} 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - {{date}} 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/{{name}}/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/{{name}}/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /src/boot/new/app/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /src/boot/new/app/README.md: -------------------------------------------------------------------------------- 1 | # {{name}} 2 | 3 | FIXME: description 4 | 5 | ## Installation 6 | 7 | Download from http://example.com/FIXME. 8 | 9 | ## Usage 10 | 11 | FIXME: explanation 12 | 13 | Run the project directly: 14 | 15 | $ boot run 16 | 17 | Run the project's tests (they'll fail until you edit them): 18 | 19 | $ boot test 20 | 21 | Build an uberjar from the project: 22 | 23 | $ boot build 24 | 25 | Run the uberjar: 26 | 27 | $ java -jar target/{{name}}-0.1.0-SNAPSHOT-standalone.jar [args] 28 | 29 | ## Options 30 | 31 | FIXME: listing of options this app accepts. 32 | 33 | ## Examples 34 | 35 | ... 36 | 37 | ### Bugs 38 | 39 | ... 40 | 41 | ### Any Other Sections 42 | ### That You Think 43 | ### Might be Useful 44 | 45 | ## License 46 | 47 | Copyright © {{year}} FIXME 48 | 49 | Distributed under the Eclipse Public License either version 1.0 or (at 50 | your option) any later version. 51 | -------------------------------------------------------------------------------- /src/boot/new/app/build.boot: -------------------------------------------------------------------------------- 1 | (def project '{{raw-name}}) 2 | (def version "0.1.0-SNAPSHOT") 3 | 4 | (set-env! :resource-paths #{"resources" "src"} 5 | :source-paths #{"test"} 6 | :dependencies '[[org.clojure/clojure "RELEASE"] 7 | [adzerk/boot-test "RELEASE" :scope "test"]]) 8 | 9 | (task-options! 10 | aot {:namespace #{'{{namespace}}}} 11 | pom {:project project 12 | :version version 13 | :description "FIXME: write description" 14 | :url "http://example/FIXME" 15 | :scm {:url "https://github.com/yourname/{{name}}"} 16 | :license {"Eclipse Public License" 17 | "http://www.eclipse.org/legal/epl-v10.html"}} 18 | repl {:init-ns '{{namespace}}} 19 | jar {:main '{{namespace}} 20 | :file (str "{{name}}-" version "-standalone.jar")}) 21 | 22 | (deftask build 23 | "Build the project locally as a JAR." 24 | [d dir PATH #{str} "the set of directories to write to (target)."] 25 | (let [dir (if (seq dir) dir #{"target"})] 26 | (comp (aot) (pom) (uber) (jar) (target :dir dir)))) 27 | 28 | (deftask run 29 | "Run the project." 30 | [a args ARG [str] "the arguments for the application."] 31 | (with-pass-thru fs 32 | (require '[{{namespace}} :as app]) 33 | (apply (resolve 'app/-main) args))) 34 | 35 | (require '[adzerk.boot-test :refer [test]]) 36 | -------------------------------------------------------------------------------- /src/boot/new/app/core.clj: -------------------------------------------------------------------------------- 1 | (ns {{namespace}} 2 | (:gen-class)) 3 | 4 | (defn -main 5 | "I don't do a whole lot ... yet." 6 | [& args] 7 | (println "Hello, World!")) 8 | -------------------------------------------------------------------------------- /src/boot/new/app/gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-history 10 | /.nrepl-port 11 | .hgignore 12 | .hg/ -------------------------------------------------------------------------------- /src/boot/new/app/hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | pom.xml 3 | pom.xml.asc 4 | *.jar 5 | *.class 6 | .gitignore 7 | .git/** 8 | 9 | syntax: regexp 10 | ^.nrepl-history 11 | ^.nrepl-port 12 | ^.lein-.* 13 | ^target/ 14 | ^classes/ 15 | ^checkouts/ 16 | -------------------------------------------------------------------------------- /src/boot/new/app/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to {{name}} 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /src/boot/new/app/test.clj: -------------------------------------------------------------------------------- 1 | (ns {{namespace}}-test 2 | (:require [clojure.test :refer :all] 3 | [{{namespace}} :refer :all])) 4 | 5 | (deftest a-test 6 | (testing "FIXME, I fail." 7 | (is (= 0 1)))) 8 | -------------------------------------------------------------------------------- /src/boot/new/default.clj: -------------------------------------------------------------------------------- 1 | (ns boot.new.default 2 | "Generate a library project." 3 | (:require [boot.new.templates :refer [renderer year date project-name 4 | ->files sanitize-ns name-to-path 5 | multi-segment]])) 6 | 7 | (defn default 8 | "A general project template for libraries. 9 | 10 | Accepts a group id in the project name: `boot new -n foo.bar/baz`" 11 | [name] 12 | (let [render (renderer "default") 13 | main-ns (multi-segment (sanitize-ns name)) 14 | data {:raw-name name 15 | :name (project-name name) 16 | :namespace main-ns 17 | :nested-dirs (name-to-path main-ns) 18 | :year (year) 19 | :date (date)}] 20 | (println "Generating a project called" name "based on the 'default' template.") 21 | (println "The default template is intended for library projects, not applications.") 22 | (->files data 23 | ["build.boot" (render "build.boot" data)] 24 | ["README.md" (render "README.md" data)] 25 | ["doc/intro.md" (render "intro.md" data)] 26 | [".gitignore" (render "gitignore" data)] 27 | [".hgignore" (render "hgignore" data)] 28 | ["src/{{nested-dirs}}.clj" (render "core.clj" data)] 29 | ["test/{{nested-dirs}}_test.clj" (render "test.clj" data)] 30 | ["LICENSE" (render "LICENSE" data)] 31 | ["CHANGELOG.md" (render "CHANGELOG.md" data)] 32 | "resources/.keep" ""))) 33 | -------------------------------------------------------------------------------- /src/boot/new/default/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - {{date}} 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - {{date}} 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/{{name}}/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/{{name}}/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /src/boot/new/default/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /src/boot/new/default/README.md: -------------------------------------------------------------------------------- 1 | # {{name}} 2 | 3 | A Clojure library designed to ... well, that part is up to you. 4 | 5 | ## Usage 6 | 7 | FIXME 8 | 9 | ## License 10 | 11 | Copyright © {{year}} FIXME 12 | 13 | Distributed under the Eclipse Public License either version 1.0 or (at 14 | your option) any later version. 15 | -------------------------------------------------------------------------------- /src/boot/new/default/build.boot: -------------------------------------------------------------------------------- 1 | (def project '{{raw-name}}) 2 | (def version "0.1.0-SNAPSHOT") 3 | 4 | (set-env! :resource-paths #{"resources" "src"} 5 | :source-paths #{"test"} 6 | :dependencies '[[org.clojure/clojure "RELEASE"] 7 | [adzerk/boot-test "RELEASE" :scope "test"]]) 8 | 9 | (task-options! 10 | pom {:project project 11 | :version version 12 | :description "FIXME: write description" 13 | :url "http://example/FIXME" 14 | :scm {:url "https://github.com/yourname/{{name}}"} 15 | :license {"Eclipse Public License" 16 | "http://www.eclipse.org/legal/epl-v10.html"}}) 17 | 18 | (deftask build 19 | "Build and install the project locally." 20 | [] 21 | (comp (pom) (jar) (install))) 22 | 23 | (require '[adzerk.boot-test :refer [test]]) 24 | -------------------------------------------------------------------------------- /src/boot/new/default/core.clj: -------------------------------------------------------------------------------- 1 | (ns {{namespace}}) 2 | 3 | (defn foo 4 | "I don't do a whole lot." 5 | [x] 6 | (println x "Hello, World!")) 7 | -------------------------------------------------------------------------------- /src/boot/new/default/gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-history 10 | /.nrepl-port 11 | .hgignore 12 | .hg/ -------------------------------------------------------------------------------- /src/boot/new/default/hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | target/** 3 | classes/** 4 | checkouts/** 5 | pom.xml 6 | pom.xml.asc 7 | *.jar 8 | *.class 9 | /.lein-* 10 | /.nrepl-history 11 | /.nrepl-port 12 | .gitignore 13 | .git/** -------------------------------------------------------------------------------- /src/boot/new/default/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to {{name}} 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /src/boot/new/default/test.clj: -------------------------------------------------------------------------------- 1 | (ns {{namespace}}-test 2 | (:require [clojure.test :refer :all] 3 | [{{namespace}} :refer :all])) 4 | 5 | (deftest a-test 6 | (testing "FIXME, I fail." 7 | (is (= 0 1)))) 8 | -------------------------------------------------------------------------------- /src/boot/new/task.clj: -------------------------------------------------------------------------------- 1 | (ns boot.new.task 2 | "Generate a Boot task project." 3 | (:require [boot.new.templates :refer [renderer year date project-name 4 | ->files sanitize-ns name-to-path 5 | multi-segment]])) 6 | 7 | (defn task 8 | "A Boot task template." 9 | [name] 10 | (let [render (renderer "task") 11 | main-ns (multi-segment (sanitize-ns name)) 12 | data {:raw-name name 13 | :name (project-name name) 14 | :namespace main-ns 15 | :nested-dirs (name-to-path main-ns) 16 | :year (year) 17 | :date (date)}] 18 | (println (str "Generating a fresh Boot task called " name ".")) 19 | (->files data 20 | ["build.boot" (render "build.boot" data)] 21 | ["README.md" (render "README.md" data)] 22 | [".gitignore" (render "gitignore" data)] 23 | [".hgignore" (render "hgignore" data)] 24 | ["src/{{nested-dirs}}.clj" (render "name.clj" data)] 25 | ["LICENSE" (render "LICENSE" data)] 26 | ["CHANGELOG.md" (render "CHANGELOG.md" data)]))) 27 | -------------------------------------------------------------------------------- /src/boot/new/task/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - {{date}} 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - {{date}} 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/{{name}}/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/{{name}}/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /src/boot/new/task/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /src/boot/new/task/README.md: -------------------------------------------------------------------------------- 1 | # {{name}} 2 | 3 | A Boot task to do many wonderful things. 4 | 5 | ## Usage 6 | 7 | FIXME: explanation 8 | 9 | Run the `{{name}}-pre` task: 10 | 11 | $ boot {{name}}-pre 12 | 13 | To use this in your project, add `[{{raw-name}} "0.1.0-SNAPSHOT"]` to your `:dependencies` 14 | and then require the task: 15 | 16 | (require '[{{namespace}} :refer [{{name}}-pre]]) 17 | 18 | Other tasks include: `{{name}}-simple`, `{{name}}-post`, `{{name}}-pass-thru`. 19 | 20 | ## License 21 | 22 | Copyright © {{year}} FIXME 23 | 24 | Distributed under the Eclipse Public License either version 1.0 or (at 25 | your option) any later version. 26 | -------------------------------------------------------------------------------- /src/boot/new/task/build.boot: -------------------------------------------------------------------------------- 1 | (def project '{{raw-name}}) 2 | (def version "0.1.0-SNAPSHOT") 3 | 4 | (set-env! :resource-paths #{"src"} 5 | :dependencies '[[org.clojure/clojure "RELEASE"] 6 | [boot/core "RELEASE" :scope "test"] 7 | [adzerk/boot-test "RELEASE" :scope "test"]]) 8 | 9 | (task-options! 10 | pom {:project project 11 | :version version 12 | :description "FIXME: write description" 13 | :url "http://example/FIXME" 14 | :scm {:url "https://github.com/yourname/{{name}}"} 15 | :license {"Eclipse Public License" 16 | "http://www.eclipse.org/legal/epl-v10.html"}}) 17 | 18 | (deftask build 19 | "Build and install the project locally." 20 | [] 21 | (comp (pom) (jar) (install))) 22 | 23 | (require '[adzerk.boot-test :refer [test]] 24 | '[{{namespace}} :refer [{{name}}-simple 25 | {{name}}-pre 26 | {{name}}-post 27 | {{name}}-pass-thru]]) 28 | -------------------------------------------------------------------------------- /src/boot/new/task/gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-history 10 | /.nrepl-port 11 | .hgignore 12 | .hg/ -------------------------------------------------------------------------------- /src/boot/new/task/hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | target/** 3 | classes/** 4 | checkouts/** 5 | pom.xml 6 | pom.xml.asc 7 | *.jar 8 | *.class 9 | /.lein-* 10 | /.nrepl-history 11 | /.nrepl-port 12 | .gitignore 13 | .git/** -------------------------------------------------------------------------------- /src/boot/new/task/name.clj: -------------------------------------------------------------------------------- 1 | (ns {{namespace}} 2 | "Example tasks showing various approaches." 3 | {:boot/export-tasks true} 4 | (:require [boot.core :as boot :refer [deftask]] 5 | [boot.util :as util])) 6 | 7 | (deftask {{name}}-simple 8 | "I'm a simple task with only setup." 9 | [A arg ARG str "the task argument"] 10 | ;; merge environment etc 11 | (println "Simple task setup:" arg) 12 | identity) 13 | 14 | (deftask {{name}}-pre 15 | "I'm a pre-wrap task." 16 | [] 17 | ;; merge environment etc 18 | (println "Pre-wrap task setup.") 19 | (boot/with-pre-wrap fs 20 | (println "Pre-wrap: Run functions on fs. Next task will run with our result.") 21 | ;; return updated filesystem (boot/commit! updated-fs) 22 | fs)) 23 | 24 | (deftask {{name}}-post 25 | "I'm a post-wrap task." 26 | [] 27 | ;; merge environment etc 28 | (println "Post-wrap task setup.") 29 | (boot/with-post-wrap fs 30 | (println "Post-wrap: Next task will run. Then we will run functions on its result (fs)."))) 31 | 32 | (deftask {{name}}-pass-thru 33 | "I'm a pass-thru task." 34 | [] 35 | ;; merge environment etc 36 | (println "Pass-thru task setup.") 37 | (boot/with-pass-thru fs 38 | (println "Pass-thru: Run functions on filesystem (fs). Next task will run with the same fs."))) 39 | -------------------------------------------------------------------------------- /src/boot/new/template.clj: -------------------------------------------------------------------------------- 1 | (ns boot.new.template 2 | (:require [boot.new.templates :refer [renderer sanitize year date ->files]])) 3 | 4 | (defn template 5 | "A meta-template for 'boot new' templates." 6 | [name] 7 | (let [render (renderer "template") 8 | data {:name name 9 | :sanitized (sanitize name) 10 | :placeholder "{{sanitized}}" 11 | :year (year) 12 | :date (date)}] 13 | (println "Generating fresh 'boot new' template project.") 14 | (->files data 15 | ["README.md" (render "README.md" data)] 16 | ["build.boot" (render "build.boot" data)] 17 | [".gitignore" (render "gitignore" data)] 18 | [".hgignore" (render "hgignore" data)] 19 | ["src/boot/new/{{sanitized}}.clj" (render "temp.clj" data)] 20 | ["resources/boot/new/{{sanitized}}/foo.clj" (render "foo.clj")] 21 | ["LICENSE" (render "LICENSE" data)] 22 | ["CHANGELOG.md" (render "CHANGELOG.md" data)]))) 23 | -------------------------------------------------------------------------------- /src/boot/new/template/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/). 3 | 4 | ## [Unreleased] 5 | ### Changed 6 | - Add a new arity to `make-widget-async` to provide a different widget shape. 7 | 8 | ## [0.1.1] - {{date}} 9 | ### Changed 10 | - Documentation on how to make the widgets. 11 | 12 | ### Removed 13 | - `make-widget-sync` - we're all async, all the time. 14 | 15 | ### Fixed 16 | - Fixed widget maker to keep working when daylight savings switches over. 17 | 18 | ## 0.1.0 - {{date}} 19 | ### Added 20 | - Files from the new template. 21 | - Widget maker public API - `make-widget-sync`. 22 | 23 | [Unreleased]: https://github.com/your-name/{{name}}/compare/0.1.1...HEAD 24 | [0.1.1]: https://github.com/your-name/{{name}}/compare/0.1.0...0.1.1 25 | -------------------------------------------------------------------------------- /src/boot/new/template/LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor tocontrol, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /src/boot/new/template/README.md: -------------------------------------------------------------------------------- 1 | # {{name}} 2 | 3 | A Leiningen template for FIXME. 4 | 5 | ## Usage 6 | 7 | FIXME 8 | 9 | ## License 10 | 11 | Copyright © {{year}} FIXME 12 | 13 | Distributed under the Eclipse Public License either version 1.0 or (at 14 | your option) any later version. 15 | -------------------------------------------------------------------------------- /src/boot/new/template/build.boot: -------------------------------------------------------------------------------- 1 | (def project '{{name}}/boot-template) 2 | (def version "0.1.0-SNAPSHOT") 3 | 4 | (set-env! :resource-paths #{"resources" "src"} 5 | ;; uncomment this if you write tests for your template: 6 | ;; :source-paths #{"test"} 7 | :dependencies '[[org.clojure/clojure "RELEASE"] 8 | [boot/new "RELEASE"] 9 | [adzerk/boot-test "RELEASE" :scope "test"]]) 10 | 11 | (task-options! 12 | pom {:project project 13 | :version version 14 | :description "FIXME: write description" 15 | :url "http://example/FIXME" 16 | :scm {:url "https://github.com/yourname/{{name}}"} 17 | :license {"Eclipse Public License" 18 | "http://www.eclipse.org/legal/epl-v10.html"}}) 19 | 20 | (deftask build 21 | "Build and install the project locally." 22 | [] 23 | (comp (pom) (jar) (install))) 24 | 25 | (require '[adzerk.boot-test :refer [test]] 26 | '[boot.new :refer [new]]) 27 | -------------------------------------------------------------------------------- /src/boot/new/template/foo.clj: -------------------------------------------------------------------------------- 1 | (def {{name}} :foo) 2 | -------------------------------------------------------------------------------- /src/boot/new/template/gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | /classes 3 | /checkouts 4 | pom.xml 5 | pom.xml.asc 6 | *.jar 7 | *.class 8 | /.lein-* 9 | /.nrepl-history 10 | /.nrepl-port 11 | .hgignore 12 | .hg/ -------------------------------------------------------------------------------- /src/boot/new/template/hgignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | target/** 3 | classes/** 4 | checkouts/** 5 | pom.xml 6 | pom.xml.asc 7 | *.jar 8 | *.class 9 | /.lein-* 10 | /.nrepl-history 11 | /.nrepl-port 12 | .gitignore 13 | .git/** -------------------------------------------------------------------------------- /src/boot/new/template/temp.clj: -------------------------------------------------------------------------------- 1 | (ns boot.new.{{name}} 2 | (:require [boot.new.templates :refer [renderer name-to-path ->files]])) 3 | 4 | (def render (renderer "{{name}}")) 5 | 6 | (defn {{name}} 7 | "FIXME: write documentation" 8 | [name] 9 | (let [data {:name name 10 | :sanitized (name-to-path name)}] 11 | (println "Generating fresh 'boot new' {{name}} project.") 12 | (->files data 13 | ["src/{{placeholder}}/foo.clj" (render "foo.clj" data)]))) 14 | -------------------------------------------------------------------------------- /src/boot/new/templates.clj: -------------------------------------------------------------------------------- 1 | (ns boot.new.templates 2 | "Boot version of leiningen.new.templates. Initially a direct copy 3 | of leiningen.new.templates (modified to depend on Boot code instead 4 | of Leiningen code), but will likely diverge over time." 5 | (:require [boot.util :as util] 6 | [clojure.java.io :as io] 7 | [clojure.string :as string]) 8 | (:import (java.util Calendar))) 9 | 10 | (defn project-name 11 | "Returns project name from (possibly group-qualified) name: 12 | 13 | mygroup/myproj => myproj 14 | myproj => myproj" 15 | [s] 16 | (last (string/split s #"/"))) 17 | 18 | (defn fix-line-separators 19 | "Replace all \\n with system specific line separators." 20 | [s] 21 | (let [line-sep (if (System/getenv "BOOT_NEW_UNIX_NEWLINES") "\n" 22 | (System/getProperty "line.separator"))] 23 | (string/replace s "\n" line-sep))) 24 | 25 | (defn slurp-to-lf 26 | "Returns the entire contents of the given reader as a single string. Converts 27 | all line endings to \\n." 28 | [r] 29 | (let [sb (StringBuilder.)] 30 | (loop [s (.readLine r)] 31 | (if (nil? s) 32 | (str sb) 33 | (do 34 | (.append sb s) 35 | (.append sb "\n") 36 | (recur (.readLine r))))))) 37 | 38 | (defn slurp-resource 39 | "Reads the contents of a resource. Temporarily converts line endings in the 40 | resource to \\n before converting them into system specific line separators 41 | using fix-line-separators." 42 | [resource] 43 | (if (string? resource) ; for 2.0.0 compatibility, can break in 3.0.0 44 | (-> resource io/resource io/reader slurp-to-lf fix-line-separators) 45 | (-> resource io/reader slurp-to-lf fix-line-separators))) 46 | 47 | (defn sanitize 48 | "Replace hyphens with underscores." 49 | [s] 50 | (string/replace s "-" "_")) 51 | 52 | (defn multi-segment 53 | "Make a namespace multi-segmented by adding another segment if necessary. 54 | The additional segment defaults to \"core\"." 55 | ([s] (multi-segment s "core")) 56 | ([s final-segment] 57 | (if (.contains s ".") 58 | s 59 | (format "%s.%s" s final-segment)))) 60 | 61 | (defn name-to-path 62 | "Constructs directory structure from fully qualified artifact name: 63 | 64 | \"foo-bar.baz\" becomes \"foo_bar/baz\" 65 | 66 | and so on. Uses platform-specific file separators." 67 | [s] 68 | (-> s sanitize (string/replace "." java.io.File/separator))) 69 | 70 | (defn sanitize-ns 71 | "Returns project namespace name from (possibly group-qualified) project name: 72 | 73 | mygroup/myproj => mygroup.myproj 74 | myproj => myproj 75 | mygroup/my_proj => mygroup.my-proj" 76 | [s] 77 | (-> s 78 | (string/replace "/" ".") 79 | (string/replace "_" "-"))) 80 | 81 | (defn group-name 82 | "Returns group name from (a possibly unqualified) name: 83 | 84 | my.long.group/myproj => my.long.group 85 | mygroup/myproj => mygroup 86 | myproj => nil" 87 | [s] 88 | (let [grpseq (butlast (string/split (sanitize-ns s) #"\."))] 89 | (if (seq grpseq) 90 | (->> grpseq (interpose ".") (apply str))))) 91 | 92 | (defn year 93 | "Get the current year. Useful for setting copyright years and such." 94 | [] (.get (Calendar/getInstance) Calendar/YEAR)) 95 | 96 | (defn date 97 | "Get the current date as a string in ISO8601 format." 98 | [] 99 | (let [df (java.text.SimpleDateFormat. "yyyy-MM-dd")] 100 | (.format df (java.util.Date.)))) 101 | 102 | ;; It'd be silly to expect people to pull in stencil just to render a mustache 103 | ;; string. We can just provide this function instead. In doing so, it is much 104 | ;; less likely that template authors will have to pull in any external 105 | ;; libraries. Though they are welcome to if they need. 106 | (defn render-text 107 | [& args] 108 | (require '[stencil.core :as stencil]) 109 | (apply (resolve 'stencil/render-string) args)) 110 | 111 | (defn renderer 112 | "Create a renderer function that looks for mustache templates in the 113 | right place given the name of your template. If no data is passed, the 114 | file is simply slurped and the content returned unchanged. 115 | 116 | render-fn - Optional rendering function that will be used in place of the 117 | default renderer. This allows rendering templates that contain 118 | tags that conflic with the Stencil renderer such as {{..}}." 119 | [name & [render-fn]] 120 | (let [render (or render-fn render-text)] 121 | (fn [template & [data]] 122 | (let [path (string/join "/" ["boot" "new" (sanitize name) template])] 123 | (if-let [resource (io/resource path)] 124 | (if data 125 | (render (slurp-resource resource) data) 126 | (io/reader resource)) 127 | (util/exit-error (println (format "Template resource '%s' not found." path)))))))) 128 | 129 | (defn raw-resourcer 130 | "Create a renderer function that looks for raw files in the 131 | right place given the name of your template." 132 | [name] 133 | (fn [file] 134 | (let [path (string/join "/" ["boot" "new" (sanitize name) file])] 135 | (if-let [resource (io/resource path)] 136 | (io/input-stream resource) 137 | (util/exit-error (println (format "File '%s' not found." path))))))) 138 | 139 | ;; Our file-generating function, `->files` is very simple. We'd like 140 | ;; to keep it that way. Sometimes you need your file paths to be 141 | ;; templates as well. This function just renders a string that is the 142 | ;; path to where a file is supposed to be placed by a template. 143 | ;; It is private because you shouldn't have to call it yourself, since 144 | ;; `->files` does it for you. 145 | (defn- template-path [name path data] 146 | (io/file name (render-text path data))) 147 | 148 | (def ^{:dynamic true} *dir* nil) 149 | (def ^{:dynamic true} *force?* false) 150 | (def ^{:dynamic true} *overwrite?* true) 151 | 152 | ;; A template, at its core, is meant to generate files and directories that 153 | ;; represent a project. This is our way of doing that. `->files` is basically 154 | ;; a mini-DSL for generating files. It takes your mustache template data and 155 | ;; any number of vectors or strings. It iterates through those arguments and 156 | ;; when it sees a vector, it treats the first element as the path to spit to 157 | ;; and the second element as the contents to put there. If it encounters a 158 | ;; string, it treats it as an empty directory that should be created. Any parent 159 | ;; directories for any of our generated files and directories are created 160 | ;; automatically. All paths are considered mustache templates and are rendered 161 | ;; with our data. Of course, this doesn't effect paths that don't have templates 162 | ;; in them, so it is all transparent unless you need it. 163 | (defn ->files 164 | "Generate a file with content. path can be a java.io.File or string. 165 | It will be turned into a File regardless. Any parent directories will be 166 | created automatically. Data should include a key for :name so that the project 167 | is created in the correct directory." 168 | [{:keys [name] :as data} & paths] 169 | (let [dir (or *dir* 170 | (-> (System/getProperty "user.dir") 171 | (io/file name) (.getPath)))] 172 | (if (or (= "." dir) (.mkdir (io/file dir)) *force?*) 173 | (doseq [path paths] 174 | (if (string? path) 175 | (.mkdirs (template-path dir path data)) 176 | (let [[path content & options] path 177 | path (template-path dir path data) 178 | options (apply hash-map options)] 179 | (.mkdirs (.getParentFile path)) 180 | (cond (not (.exists path)) 181 | (io/copy content path) 182 | 183 | (:append options) 184 | (with-open [w (io/writer path :append true)] 185 | (io/copy content w)) 186 | 187 | (or *overwrite?* *force?* (:overwrite options)) 188 | (io/copy content path) 189 | 190 | :else 191 | (println (str path " exists." 192 | " Use -f / --force to overwrite it."))) 193 | (when (:executable options) 194 | (.setExecutable path true))))) 195 | (println (str "Could not create directory " dir 196 | ". Maybe it already exists?" 197 | " Use -f / --force to overwrite it."))))) 198 | -------------------------------------------------------------------------------- /src/boot/new_helpers.clj: -------------------------------------------------------------------------------- 1 | (ns boot.new-helpers 2 | "The top-level logic for the new task. This namespace is dynamically 3 | loaded into the new task so as to reduce and delay dependencies." 4 | (:require [clojure.string :as str] 5 | [boot.core :as core] 6 | [boot.new.templates :as bnt] 7 | [boot.util :as util] 8 | ;; this is Boot's version with no Leiningen dependencies: 9 | [leiningen.new.templates :as lnt]) 10 | (:import java.io.FileNotFoundException)) 11 | 12 | (def ^:dynamic *debug* nil) 13 | (def ^:dynamic *use-snapshots?* false) 14 | (def ^:dynamic *template-version* nil) 15 | 16 | (defn resolve-remote-template 17 | "Given a template name, attempt to resolve it as a Boot template first, 18 | then as a Leiningen template. Return the type of template we found." 19 | [template-name] 20 | (let [selected (atom nil) 21 | failure (atom nil) 22 | boot-tmp-name (str template-name "/boot-template") 23 | lein-tmp-name (str template-name "/lein-template") 24 | tmp-version (cond *template-version* *template-version* 25 | *use-snapshots?* "(0.0.0,)" 26 | :else "RELEASE") 27 | output 28 | (with-out-str 29 | (binding [*err* *out*] 30 | (try 31 | (core/merge-env! :dependencies [[(symbol boot-tmp-name) 32 | tmp-version]]) 33 | 34 | (reset! selected :boot) 35 | (catch Exception e 36 | (when (and *debug* (> *debug* 2)) 37 | (println "Unable to find Boot template:") 38 | (clojure.stacktrace/print-stack-trace e)) 39 | (reset! failure e) 40 | (try 41 | (core/merge-env! :dependencies [['leiningen-core "2.5.3"] 42 | ['slingshot "0.10.3"] 43 | [(symbol lein-tmp-name) 44 | tmp-version]]) 45 | (reset! selected :leiningen) 46 | (catch Exception e 47 | (when (and *debug* (> *debug* 1)) 48 | (println "Unable to find Leiningen template:") 49 | (clojure.stacktrace/print-stack-trace e)) 50 | (reset! failure e)))))))] 51 | (when *debug* 52 | (println "Output from locating template:") 53 | (println output)) 54 | (if @selected 55 | (let [sym-name (str (name @selected) ".new." template-name)] 56 | (try 57 | (require (symbol sym-name)) 58 | @selected 59 | (catch Exception e 60 | (when *debug* 61 | (when (> *debug* 3) 62 | (println "Boot environment at failure:" (core/get-env))) 63 | (println "Unable to require the template symbol:" sym-name) 64 | (clojure.stacktrace/print-stack-trace e) 65 | (when (> *debug* 1) 66 | (clojure.stacktrace/print-cause-trace e))) 67 | (util/exit-error (println "Could not load template, require of" 68 | sym-name 69 | "failed with:" (.getMessage e)))))) 70 | (util/exit-error (println output) 71 | (println "Failed with:" (.getMessage @failure)) 72 | (println "Could not load artifact for template:" template-name) 73 | (println (format (str "\tTried coordinates:\n" 74 | "\t\t[%s \"%s\"]\n" 75 | "\t\t[%s \"%s\"]") 76 | boot-tmp-name tmp-version 77 | lein-tmp-name tmp-version)))))) 78 | 79 | (defn resolve-template 80 | "Given a template name, resolve it to a symbol (or exit if not possible)." 81 | [template-name] 82 | (if-let [type (try (require (symbol (str "boot.new." template-name))) 83 | :boot 84 | (catch FileNotFoundException _ 85 | (resolve-remote-template template-name)))] 86 | (let [the-ns (str (name type) ".new." template-name)] 87 | (if-let [sym (resolve (symbol the-ns template-name))] 88 | sym 89 | (util/exit-error (println "Found template" template-name "but could not resolve" 90 | (str the-ns "/" template-name) "within it.")))) 91 | (util/exit-error (println "Could not find template" template-name "on the classpath.")))) 92 | 93 | (defn create* 94 | "Given a template name, a project name and list of template arguments, 95 | perform sanity checking on the project name and, if it's sane, then 96 | generate the project from the template." 97 | [template-name project-name args] 98 | (cond 99 | (and (re-find #"(?i)(? myproj 14 | myproj => myproj" 15 | [s] 16 | (last (string/split s #"/"))) 17 | 18 | (defn fix-line-separators 19 | "Replace all \\n with system specific line separators." 20 | [s] 21 | (let [line-sep (if (System/getenv "LEIN_NEW_UNIX_NEWLINES") "\n" 22 | (System/getProperty "line.separator"))] 23 | (string/replace s "\n" line-sep))) 24 | 25 | (defn slurp-to-lf 26 | "Returns the entire contents of the given reader as a single string. Converts 27 | all line endings to \\n." 28 | [r] 29 | (let [sb (StringBuilder.)] 30 | (loop [s (.readLine r)] 31 | (if (nil? s) 32 | (str sb) 33 | (do 34 | (.append sb s) 35 | (.append sb "\n") 36 | (recur (.readLine r))))))) 37 | 38 | (defn slurp-resource 39 | "Reads the contents of a resource. Temporarily converts line endings in the 40 | resource to \\n before converting them into system specific line separators 41 | using fix-line-separators." 42 | [resource] 43 | (if (string? resource) ; for 2.0.0 compatibility, can break in 3.0.0 44 | (-> resource io/resource io/reader slurp-to-lf fix-line-separators) 45 | (-> resource io/reader slurp-to-lf fix-line-separators))) 46 | 47 | (defn sanitize 48 | "Replace hyphens with underscores." 49 | [s] 50 | (string/replace s "-" "_")) 51 | 52 | (defn multi-segment 53 | "Make a namespace multi-segmented by adding another segment if necessary. 54 | The additional segment defaults to \"core\"." 55 | ([s] (multi-segment s "core")) 56 | ([s final-segment] 57 | (if (.contains s ".") 58 | s 59 | (format "%s.%s" s final-segment)))) 60 | 61 | (defn name-to-path 62 | "Constructs directory structure from fully qualified artifact name: 63 | 64 | \"foo-bar.baz\" becomes \"foo_bar/baz\" 65 | 66 | and so on. Uses platform-specific file separators." 67 | [s] 68 | (-> s sanitize (string/replace "." java.io.File/separator))) 69 | 70 | (defn sanitize-ns 71 | "Returns project namespace name from (possibly group-qualified) project name: 72 | 73 | mygroup/myproj => mygroup.myproj 74 | myproj => myproj 75 | mygroup/my_proj => mygroup.my-proj" 76 | [s] 77 | (-> s 78 | (string/replace "/" ".") 79 | (string/replace "_" "-"))) 80 | 81 | (defn group-name 82 | "Returns group name from (a possibly unqualified) name: 83 | 84 | my.long.group/myproj => my.long.group 85 | mygroup/myproj => mygroup 86 | myproj => nil" 87 | [s] 88 | (let [grpseq (butlast (string/split (sanitize-ns s) #"\."))] 89 | (if (seq grpseq) 90 | (->> grpseq (interpose ".") (apply str))))) 91 | 92 | (defn year 93 | "Get the current year. Useful for setting copyright years and such." 94 | [] (.get (Calendar/getInstance) Calendar/YEAR)) 95 | 96 | (defn date 97 | "Get the current date as a string in ISO8601 format." 98 | [] 99 | (let [df (java.text.SimpleDateFormat. "yyyy-MM-dd")] 100 | (.format df (java.util.Date.)))) 101 | 102 | ;; It'd be silly to expect people to pull in stencil just to render a mustache 103 | ;; string. We can just provide this function instead. In doing so, it is much 104 | ;; less likely that template authors will have to pull in any external 105 | ;; libraries. Though they are welcome to if they need. 106 | (defn render-text 107 | [& args] 108 | (require '[stencil.core :as stencil]) 109 | (apply (resolve 'stencil/render-string) args)) 110 | 111 | (defn renderer 112 | "Create a renderer function that looks for mustache templates in the 113 | right place given the name of your template. If no data is passed, the 114 | file is simply slurped and the content returned unchanged. 115 | 116 | render-fn - Optional rendering function that will be used in place of the 117 | default renderer. This allows rendering templates that contain 118 | tags that conflic with the Stencil renderer such as {{..}}." 119 | [name & [render-fn]] 120 | (let [render (or render-fn render-text)] 121 | (fn [template & [data]] 122 | (let [path (string/join "/" ["leiningen" "new" (sanitize name) template])] 123 | (if-let [resource (io/resource path)] 124 | (if data 125 | (render (slurp-resource resource) data) 126 | (io/reader resource)) 127 | (util/exit-error (println (format "Template resource '%s' not found." path)))))))) 128 | 129 | (defn raw-resourcer 130 | "Create a renderer function that looks for raw files in the 131 | right place given the name of your template." 132 | [name] 133 | (fn [file] 134 | (let [path (string/join "/" ["leiningen" "new" (sanitize name) file])] 135 | (if-let [resource (io/resource path)] 136 | (io/input-stream resource) 137 | (util/exit-error (println (format "File '%s' not found." path))))))) 138 | 139 | ;; Our file-generating function, `->files` is very simple. We'd like 140 | ;; to keep it that way. Sometimes you need your file paths to be 141 | ;; templates as well. This function just renders a string that is the 142 | ;; path to where a file is supposed to be placed by a template. 143 | ;; It is private because you shouldn't have to call it yourself, since 144 | ;; `->files` does it for you. 145 | (defn- template-path [name path data] 146 | (io/file name (render-text path data))) 147 | 148 | (def ^{:dynamic true} *dir* nil) 149 | (def ^{:dynamic true} *force?* false) 150 | 151 | ;; A template, at its core, is meant to generate files and directories that 152 | ;; represent a project. This is our way of doing that. `->files` is basically 153 | ;; a mini-DSL for generating files. It takes your mustache template data and 154 | ;; any number of vectors or strings. It iterates through those arguments and 155 | ;; when it sees a vector, it treats the first element as the path to spit to 156 | ;; and the second element as the contents to put there. If it encounters a 157 | ;; string, it treats it as an empty directory that should be created. Any parent 158 | ;; directories for any of our generated files and directories are created 159 | ;; automatically. All paths are considered mustache templates and are rendered 160 | ;; with our data. Of course, this doesn't effect paths that don't have templates 161 | ;; in them, so it is all transparent unless you need it. 162 | (defn ->files 163 | "Generate a file with content. path can be a java.io.File or string. 164 | It will be turned into a File regardless. Any parent directories will be 165 | created automatically. Data should include a key for :name so that the project 166 | is created in the correct directory." 167 | [{:keys [name] :as data} & paths] 168 | (let [dir (or *dir* 169 | (-> (System/getProperty "user.dir") 170 | (io/file name) (.getPath)))] 171 | (if (or (= "." dir) (.mkdir (io/file dir)) *force?*) 172 | (doseq [path paths] 173 | (if (string? path) 174 | (.mkdirs (template-path dir path data)) 175 | (let [[path content & options] path 176 | path (template-path dir path data) 177 | options (apply hash-map options)] 178 | (.mkdirs (.getParentFile path)) 179 | (io/copy content (io/file path)) 180 | (when (:executable options) 181 | (.setExecutable path true))))) 182 | (println (str "Could not create directory " dir 183 | ". Maybe it already exists?" 184 | " See also :force or --force"))))) 185 | -------------------------------------------------------------------------------- /src/leiningen/release.clj: -------------------------------------------------------------------------------- 1 | (ns leiningen.release 2 | "Adapted from Leiningen's code by stripping things down to 3 | just one method to support one particular template (play-clj) 4 | that uses lein-droid, which expects parse-semantic-version 5 | to be available here." 6 | (:require [boot.util :as util])) 7 | 8 | (defn string->semantic-version 9 | "Create map representing the given version string. Returns nil if the 10 | string does not follow guidelines setforth by Semantic Versioning 2.0.0, 11 | http://semver.org/" 12 | [version-string] 13 | ;; ..[-][-SNAPSHOT] 14 | (if-let [[_ major minor patch qualifier snapshot] 15 | (re-matches 16 | #"(\d+)\.(\d+)\.(\d+)(?:-(?!SNAPSHOT)([^\-]+))?(?:-(SNAPSHOT))?" 17 | version-string)] 18 | (->> [major minor patch] 19 | (map #(Integer/parseInt %)) 20 | (zipmap [:major :minor :patch]) 21 | (merge {:qualifier qualifier 22 | :snapshot snapshot})))) 23 | 24 | (defn parse-semantic-version 25 | "Create map representing the given version string. Aborts with exit code 1 26 | if the string does not follow guidelines setforth by Semantic Versioning 2.0.0, 27 | http://semver.org/" 28 | [version-string] 29 | (or (string->semantic-version version-string) 30 | (util/exit-error (println "Unrecognized version string:" version-string)))) 31 | --------------------------------------------------------------------------------