Liking cljdoc? Tell your friends :D

license clojars

Application template

Intro

This Application template helps you to quick start new application project using clojure deps cli and clj-new.

This Application template provides:

  • project control via Justfile (see just) and scripting using babashka;

  • environment variables control using direnv utility;

  • editor configuration via .editorconfig file;

  • configured clj-kondo linter;

  • configured cljstyle formatter;

  • run tests using kaocha.

This template will give you the following basic project workflow:

mike@mbp02 just
List of available recipes
Available recipes:
    build              # Build uberjar file (as an application)
    bump level='patch' # Bump version artifact in `version_id` file, level may be one of: major, minor, patch, alpha, beta, rc, release.
    clean              # Clean target folder
    default            # Help
    deploy             # Deploy uberjar file to remote repository (stub)
    format             # Format source code
    install            # Install uberjar locally (requires the pom.xml file)
    javac              # Compile java sources (if any)
    lint               # Lint source code
    outdated           # Check for outdated dependencies
    repl               # Run Clojure repl
    requirements       # Install project requirements (OS will be detected automatically)
    run                # Run application
    standalone         # Create a standalone application with bundled JDK (using jlink, JDK 9+)
    test               # Run tests

See also:

Using Application template

New Application project

Before creating a project from this template, please install prerequisites (see below). To create a project from this template just run:

    clojure -X:clj-new :template rssysapp :name myname/myapp
    cd myapp

where :clj-new is alias in ~/.clojure/deps.edn file (see prerequisites below).

Please, see README.adoc in a root folder of created project to install other tools once.

Install prerequisites

All these tools you need to install only once.

  1. Install clojure deps cli tools

    1. MacOS

      brew install clojure/tools/clojure
    2. Linux

      Ensure that the following dependencies are installed in OS: bash, curl, rlwrap, and Java.

      curl -O https://download.clojure.org/install/linux-install-1.10.2.790.sh
      chmod +x linux-install-1.10.2.790.sh
      sudo ./linux-install-1.10.2.790.sh
  2. Install latest clj-new library to a file ~/.clojure/deps.edn

    {
     :aliases {
               :clj-new     {:extra-deps {seancorfield/clj-new {:mvn/version "1.1.243"}}
                             :exec-fn    clj-new/create}
              }
    
     }
  3. Install just utility

    1. MacOS

      brew install just
    2. Linux

      wget https://github.com/casey/just/releases/download/v0.8.3/just-v0.8.3-x86_64-unknown-linux-musl.tar.gz
      
      tar -zxvf just-v0.8.3-x86_64-unknown-linux-musl.tar.gz just
      
      sudo mv ./just /usr/local/bin
  4. Install babashka

    1. MacOS

      brew install borkdude/brew/babashka
    2. Linux

      sudo bash < <(curl -s https://raw.githubusercontent.com/babashka/babashka/master/install)
Install direnv
  1. MacOS

    brew install direnv
  2. Linux

    sudo bash < <(curl -s https://direnv.net/install.sh)

Also, don’t forget to install direnv hook for your shell. Example for zsh shell:

echo 'eval "$(direnv hook zsh)"\n' >> ~/.zshrc

Managing this project

Clean project

To clean target folder run:

just clean

Bump artifact version

To set release version run:

just bump release

To update patch version run:

just bump patch

Build project

To build this template run:

just build

This command will produce deployable jar file and update the generated pom.xml file to keep the dependencies synchronized with your deps.edn file. You can update the version information in the pom.xml using the version_id file.

Install artifact

To install jar file to local .m2 run:

just install

Deploy artifact

To deploy jar file to Clojars run:

just deploy

Check .env.private file for correct values of user and password.

Check old dependencies

To check project for outdated dependencies run:

just outdated

License

Copyright © 2021 Mike Ananev
Distributed under the Eclipse Public License 2.0 or (at your option) any later version.

Can you improve this documentation?Edit on GitHub

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

× close