This article is a work in progress
Clojure CLI tools is a relatively new approach to creating an managing projects. The Edge project from JUXT takes the approach and extends it with its own features, such as being able to update projects created from the edge configuration.
Unlike Leiningen and Boot templates which are one of tasks, you can update a project you created a while ago with Edge and bring it up to date. It will be interesting to try this out in future articles.
Please see earlier articles in this series for background:
- Experimenting With Clojure CLI Tools Options
- A Deeper Understanding of Clojure CLI Tools
- Getting Started With Clojure CLI Tools
Edge also has editor setup guides for Clojure for Atom, Emacs, Spacemacs, Intellij (Cursive), Vim and VS Code with Calva. There does not seem to be anything specific to Edge here though, so assume it doesnt require anything to be configured.
Using Emacs or Spacemacs, you may need to specify one or more aliases to use with Edge, so see my article on CIDER jack-in to Clojure CLI projects from Spacemacs
You also need to have a Git client installed.
If you are starting a new project, then you can simply create a local Git repository and add Edge as a remote repository and pull
It will be interesting to try this approach out on older projects. I assume the project has to have a deps.edn file already (something interesting to test).
Although we have added Edge to our new project, we dont yet have an app. There are examples you can run, but you probably want to create your own app rather than unpicking an existing one (also if the example updates, I am not sure what that would do to your changes).
Lets start with creating a simple Clojure api for our study group.
In the root of the project run the
./bin/app command and give it the name of your project. You need to specify a namespace with the overall domain (your company or GitHub account for example) and the project name. I am using
practicalli as the domain namespace and
study-guide-api as the project namespace.
You should see output telling you the a new app has been created using the
A new directory has been created using the domain and project namespace names you provided. In our example,
As we are using a Clojure project, we can start a REPL using by just including the
:dev alias when we run Clojure on the command line.
Take a look at the
practicalli.study-group-apidirectory for more options, especially if you create a ClojureScript or SASS project.
The project will download a noticable number of dependencies at this point, so time for a quick cup of peppermint tea…
Once the dependencies are downloaded you should see the standard
I had expected rebel readline instead, but this is available when running the relevant Edge scripts,
/bin/rebel. Keep in the
practicalli.study-guide-api directory root and call the rebel script with the
There will be just a few more dependencies to download, so this should be quick. You should see the rebel readline prompt as well as a message to call the
At the REPL prompt, type
(go) to start the system for the application. This is a common approach for applications that have some component system to start/stop/reload your application or individual components of your application.
Open your browser at localhost:3636 to see the default project.
If you make any changes to the code you can reload them by calling
(reset) in the REPL.
Samples taken from https://juxt.pro/edge/docs/first-component.html
Add a yada resource - its just a Clojure function
yada is a web library for Clojure, designed to support the creation of production services via HTTP.
Now we create a component for the yada resource for the web router to depend on.
To do this, we use defmethod on ig/init-key.
ig/init-key takes two arguments but we are not going to use them, so we can use the
_ to provide an argument so the defmethod is valid but not use the argument values.
now update our system to include our new component. Open “src/config.edn” in your editor. Within the :ig/system map, add a key
Here is a brief explanation of the Integrant configuration file,
Now back to the REPL and call
(reset) to stop the app, load in the new resource and start again.
Pulling edge into master will add a number of files
This contains patterns specific to the libraries this project uses, such at the
.cpcache used by Clojure CLI tools and the
to keep a history of commands entered when running rebel readline based REPL.
There are 4 years worth of commits added, so if you wanted to see how Edge has evolved then fire up your favourite git client
This work is licensed under a Creative Commons Attribution 4.0 ShareAlike License, including custom images & stylesheets. Permissions beyond the scope of this license may be available at @jr0cket