{:title "Clojure Cookbook" :category :cookbook :index 20 :related [["intro/basic-example" "Basic Example"] ["intro/useful-example" "A More Useful Example"]]}
This is a collection of examples on how to build various kinds of Clojure
sources. There is a Clojure plugin
available that provides some functionality for building common Clojure projects. In order
to use it, include it in your deps.edn:
{:deps {com.monkeyci/plugin-clj {:mvn/version "0.4.0"}}}
The most recent version can be found on Clojars.
A library using Leiningen, with default file layout and that's being published to Clojars:
(ns build
(:require [monkey.ci.plugin.clj :as clj]))
(clj/lein-library {})
This assumes build parameters exist with CLOJARS_USERNAME and CLOJARS_PASSWORD.
It creates two jobs, test and publish.
A library using the Clojure CLI, with default
file layout, and dependencies in deps.edn:
(ns build
(:require [monkey.ci.plugin.clj :as clj]))
(clj/deps-library {})
The same requirements as for Leiningen apply: credentials need to exist in the build parameters,
and it creates two jobs, called test and publish.
Just running unit tests using Leiningen in subdirectory subdir.
Only one job is created, called lein-test.
(ns build
(:require [monkey.ci.api :as m]
[monkey.ci.plugin.clj :as clj]))
;; This will execute 'lein test'
(-> (clj/lein-test {:test-alias "test"
:test-job-id "lein-test"})
(m/work-dir "subdir"))
Similarly, running unit tests using Clojure CLI in subdirectory subdir.
Only one job is created, called deps-test.
(ns build
(:require [monkey.ci.api :as m]
[monkey.ci.plugin.clj :as clj]))
;; This will execute 'clojure -X:test' in 'subdir'
(-> (clj/deps-test {:test-alias "test"
:test-job-id "deps-test"})
(m/work-dir "subdir"))
Running a specific Leiningen alias, in a job named custom-job:
(ns build
(:require [monkey.ci.plugin.clj :as clj]))
;; This will execute 'lein custom' in a container with default opts
(clj/clj-lein "custom-job" {} ["lein custom"])
Running a specific CLI main function (using -M), in a job named custom-job
which is dependent on other-job.
(ns build
(:require [monkey.ci.api :as m]
[monkey.ci.plugin.clj :as clj]))
;; This will execute 'clojure -M:custom' in a container with default opts
(-> (clj/clj-deps "custom-job" {} "-M:custom")
(m/depends-on "other-job"))
Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |