Liking cljdoc? Tell your friends :D

Development

When working with a Polylith codebase, you are free to choose any editor/IDE you like, for example:

Generic Setup

We only currently specifically describe IntelliJ IDEA with Cursive Setup.

If you are using a different IDE, here’s the generic goals:

  1. Setup your IDE’s REPL to startup with dev and test aliases

  2. Notice that your ./deps.edn already has development/src on the path for the dev alias

  3. Add sample source development/src/dev/lisa.clj:

    (ns dev.lisa)
    
    (+ 1 2 3)
  4. Evaluate dev.lisa in your IDE REPL to test.

  5. Celebrate a successful IDE setup!

IntelliJ IDEA with Cursive Setup

Here, we share some specific setup instructions when using Cursive.

Cursive Setup

First, make sure you have tools.deps configured correctly.

To import a Polylith workspace as a project:

  1. Select File > New > Project from Existing Sources…​ from the menu.

  2. A wizard will guide you through the import:

    1. Start with selecting the ./deps.edn file

    2. When asked, choose your desired version of the Java SDK

    3. Otherwise, hit Next and finally Create.

If you are using Cursive 1.13.0 or later, you must enable Resolve over whole project under
File > Settings…​ > Languages & Frameworks > Clojure > Project Specific Options:

idea resolve over whole project

From the Clojure Deps tab (by default, it’s on the far right), enable dev under Aliases, then press the icon with two arrows to refresh:

activate dev alias

To create a REPL, select Current File > Edit Configurations…​:

edit configuration

Then click the + sign and select Clojure REPL > Local:

create local repl

Configure like so:

  • Name: type REPL

  • Which type of REPL to run choose nREPL

  • How to run it choose Run with Deps

    • Options: type -A:dev:test

  • Common Options > Module: select your Polylith workspace directory, e.g., example

Press OK. Now start the REPL in debug mode by clicking the bug icon:

debug

Under the REPL view, you should soon see something like:

Clojure 1.11.1
nREPL server started on port 56855 on host localhost - nrepl://localhost:56855

You have configured everything tools.deps needs and are ready to write some Clojure code!

Trying Out Your Development Environment

Look at the generated ./deps.edn file. Notice that it already includes development/src on the path under the :dev alias:

 :aliases  {:dev {:extra-paths ["development/src"]

(You might remember we had you enable the dev alias above under Clojure Deps and for the REPL via -A:dev:test.)

To get started, create a dev namespace. We suggest you use dev as a top namespace here, not your workspace top namespace. This strategy keeps your production code entirely separate from your development code.

One way to structure dev code is to give each developer their own namespace under dev. Following this pattern, create the namespace dev.lisa:
Right-click on the development/src directory, select New > Clojure Namespace, and type dev.lisa.

A dialog will pop up and ask you if you want to add the file to git:

add file to git

Check Don’t ask again and click the Add button.

If the namespace is not recognized, you may need to click the icon with two arrows under the Clojure Deps tab to refresh:

refresh

Now you can write some code in lisa.clj:

(ns dev.lisa)

(+ 1 2 3)

Load the namespace by sending (ns dev.lisa) to the REPL.

Send (+ 1 2 3) to the REPL. You should see 6 in the REPL view.

Congratulations, you now have a working development environment!

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close