A template for starting a clj tools based project.
Batteries included features:
- Project dirs/file basics
- src and test directory structure.
- .gitignore, build.clj, deps.edn, LICENSE, README.
- Tasks: Taskfile for common development tasks.
- Dev: REPL with nREPL and cider-nrepl for Calva/VSCode.
- Quality: Linting with 'clj-kondo', formatting with 'cljfmt'.
- Tests: Clojure 'test-runner' from Cognitect.
- Dependencies: Dependency version checks with 'antq'.
- Packaging: Create jars/uberjars with 'clojure.tools.build'.
- Deploy: Publish jars/uberjars to clojars via 'deps-deploy'.
- Docker: Dockerfile for containerized builds.
- CI/CD: Github Workflow that runs tests and packages.
After cloning this template, rename the project to your own:
./scripts/rename-project.sh my-new-project my-github-user "My Name"This replaces all references to the current project name, GitHub username, and author in source files, configs, and directory names. The GitHub username and author are optional.
Run the -main function in the namespace/core.clj file:
- Method 1: Implied -main function in the namespace. Args sent as a list.
clj -M:run-m- Method 2: Explicit namespace+function. Args sent as a key value map.
clj -X:run-xA Taskfile is provided as a convenience wrapper around the clj commands documented below.
List all available tasks:
taskExamples:
task test # Run tests
task build # Build uberjar
task lint # Lint code
task fmt # Format code
task docker:build # Build Docker image
task outdated # Check for outdated depsStart a dev REPL with nREPL for Calva/VSCode:
clj -M:devLint code:
clj -M:lint src/ test/Check formatting:
clj -M:cljfmt check src/ test/Fix formatting:
clj -M:cljfmt fix src/ test/Run tests (excludes integration and strict tests):
clj -M:testRun tests matching a pattern:
clj -X:test-m :p coreRun integration tests:
clj -X:test-integrationRun all tests via build (no exclusions):
clj -T:build testCheck for outdated dependencies:
clj -M:outdatedUpgrade outdated dependencies.
clj -M:outdated --upgradeBuild a JAR.
clj -T:build jarBuild an uberJAR.
clj -T:build uberTest, write pom, and build a JAR.
clj -T:build ci-jarTest, write pom, and build an uberJAR.
clj -T:build ci-uberClean packaging area.
clj -T:build cleanDeploy jars to clojars:
;; env vars for clojars
CLOJARS_USERNAME=username
CLOJARS_PASSWORD=clojars-token
clj -T:build deploy