Skip to content

Instantly share code, notes, and snippets.

@wdhowe
Last active February 3, 2024 21:11
Show Gist options
  • Save wdhowe/78bececa96e577bf26139e4bdc501d47 to your computer and use it in GitHub Desktop.
Save wdhowe/78bececa96e577bf26139e4bdc501d47 to your computer and use it in GitHub Desktop.
Creating Clojure projects with Leiningen

Leiningen Projects

Leiningen is another method for managing Clojure projects. It is similar to pipenv in the Python world, in that it manages project space and dependent packages.

Offical Site: https://leiningen.org/

Install Leiningen

  • Download the installer

    wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein
  • Put the installer in a location in your PATH and make executable

    mv lein ~/bin/
    chmod +x ~/bin/lein
  • Run lein. It will auto setup everything you need.

    ./lein

Using Leiningen

Full tutorial/more details: https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md

  • View available lein commands

    lein help
  • Create a new app project (replace "hello_world" with your project name)

    lein new app hello-world
    
    # change into the new project directory for the rest of the commands
    cd hello-world
  • Run the "-main" part of your app

    lein run
  • Run the project's unit tests

    lein test
  • Run the interactive REPL (read eval print loop)

    lein repl
  • Create a standalone executable jar file of your entire project

    # create the standalone jar
    lein uberjar
    
    # run the standalone jar
    java -jar target/uberjar/hello-world-0.1.0-SNAPSHOT-standalone.jar

    Plugins

    You may wish to install lein plugins for further customization across projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment