Creating Clojure projects

Creating Clojure projects save code as you are learning or developing applications. Using a project is the quickest way to test development tools are configured correctly.

Creating projects using a template is the quickest way to get started, as the template will create the project structure and add libraries the project. Practicalli recommends the Clojure CLI tools and clj-new to create projects.

Hint::Install clj-new and other aliases

Follow the install clojure guide to install all the alias used in this guide

Create a project with clj-new and the app template

Open a terminal window and change to a suitable folder

  1. cd projects/clojure

Create a new project using clj-new and the app template. If you prefer, use your company name or GitHub name instead of practicalli and change playground to the name of the application.

  1. clojure -A:new app practicalli/playground

Change into the directory and test the project runs by starting a REPL with rebel readline

  1. cd playground
  2. clj -A:rebel

Hint::Install rebel and other aliases

Follow the install clojure guide to install all the alias used in this guide

A repl prompt should appear.

Clojure REPL rebel readline

Type code expressions at the repl prompt and press RETURN to evaluate them.

  1. (+ 1 2 3 4 5)

NOTE::Try the project with your preferred editor

Go to the Editor user guides

Other templates

clj-new has 3 templates that create deps.edn based projects

  • app - a project that will run on the command line
  • lib - a project that will be used as a library (added to other projects as a dependency)
  • template - a project for creating your own custom templates.

clj-new can create projects from deps.edn, Leiningen and Boot templates. A wide range of templates have been created by the Clojure community which can be found by searching on Clojars.org:

clj-deps does not change Leiningen or Boot templates into deps.edn projects. If a deps.edn file is not part of the project it should be manually created.