Gaiwan's Clojure Conventions
Project Structure
- We use Clojure CLI /
deps.edn -
srcis for source files, Clojure and ClojureScript or cljc - The main namespace has at least two segments, an org name and a project name, so
src/org_name/project_name.clj - Optionally but recommended, use a reverse domain name for the org name, so you get a (at least) 3-segment name, e.g.
co.gaiwan.our-app - This main namespace has a
-mainfunction that uses lambdaisland/cli - Other namespaces in the project are prefixed with the org+project name, e.g.
co.gaiwan.our-app.some-ns, in other words all other source files go undersrc/org_name/project_name/ - The following will refer to
org-name.project-nameasprefix -
resourcesis for non-source files that should be accessible on the classpath - Avoid having files directly inside
resources, especially with generic names (config.edn,index.html), because they could easily conflict with other stuff on the classpath. Useprefixinstead, e.g.resources/org_name/project_name/config.edn -
prefix.configrequirescom.lambdaisland.config, loads the config, sets theprefix, and exposes it to the rest of the app by wrapping the access functions - Config follows the conventions as described in the lambdaisland/config README
Tooling
- We use babashka scripts where applicable
-
bb.ednshould include launchpad and/or lambdaisland/cli -
bin/devis where we create dev tasks, it's a bb script using li/cli -
bin/launchpadis a WellKnownIdentifier that starts launchpad -
bin/kaochais a WellKnownIdentifier that runs tests -
*.local.*and*.localare gitignored (deps.local.edn,config.local.edn,.env.local, etc)