https://github.com/thoughtworksinc/lein-filegen
A leiningen plugin to generate files
https://github.com/thoughtworksinc/lein-filegen
Last synced: about 1 month ago
JSON representation
A leiningen plugin to generate files
- Host: GitHub
- URL: https://github.com/thoughtworksinc/lein-filegen
- Owner: ThoughtWorksInc
- License: epl-1.0
- Created: 2014-02-13T12:24:00.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-02-13T13:12:50.000Z (over 11 years ago)
- Last Synced: 2025-04-05T21:51:15.823Z (2 months ago)
- Language: Clojure
- Size: 117 KB
- Stars: 6
- Watchers: 18
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lein-filegen
A Leiningen plugin that generates files based on the instructions in project.clj.
This is useful for generating artefacts outside of src such as configuration files etc.
## Usage
Use this for project-level plugins:
Put `[lein-filegen "0.1.0-SNAPSHOT"]` into the `:plugins` vector of your project.clj.
## Configuration
To use lein-filegen you'll need to add a :filegen vector into your project.clj.
The filegen vector contains a hash which prescribes how to generate a file. It needs to know:
* `:target` file to generate
* `:data` from which to generate the file
* `:template-fn` to transform the data into the string which will be written to the file
* `:requires`, an optional argument to require any namespaces for the template-fn to workIn full it looks something like this:
```clojure
:filegen [{:data {:environment ~(System/getenv "ENVIRONMENT")
:database-url ~(System/getenv "DATABASE_URL")}
:requires '[clojure.data.json :refer [write-str]]
:template-fn write-str
:target "resources/configuration/config.json"}]
```The above takes the data and converts it to a json file.
As it's a vector filegen can take multiple hash instructions for different files.
## Run
$ lein filegen## License
Copyright © 2014 Thoughtworks Inc
Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.