Liking cljdoc? Tell your friends :D

build-clj

This is fooheads build.clj, used in our libs and projects.

To use it, first create a file in you librarys root called lib.edn.

{:name com.fooheads/example-lib
 :version "1.3.2"

If you are to deploy it to clojars, the namespace of the symbol id should be your clojars group-id (com.fooheads in this example).

Then add this alias to your deps.edn:

:build
{:deps
 {com.fooheads/build-clj {:mvn/version "1.1.0"}}
  :ns-default fooheads.build}

If you want to deploy to a private maven repository, you can att a :respository key to lib.edn with the URL of the repository:

{:name com.fooheads/example-lib
 :version "1.3.2"
 :repository "https://maven.pkg.github.com/OWNER/REPOSITORY"}

or to an S3 bucket:

{:name com.fooheads/example-lib
 :version "1.3.2"
 :repository "s3p://some-s3-bucket/releases""}

That's it. Now you can do the following:

clean

Cleans the target folder.

clojure -T:build clean

jar

Calls clean and then builds a jar file with name (excluding namespace/group) and version from lib.edn

clojure -T:build jar

Example output:

Build folder "target" removed
Jar file created: "target/stdlib-0.1.12.jar"

uber

Builds an uberjar (standalone JAR with all dependencies bundled). If a -main function is found in src/, it will be AOT compiled and set as the main entry point.

clojure -T:build uber

Example output:

Build folder "target" removed
Uberjar created: "target/example-lib-1.3.2-standalone.jar"
Main entry point: example.core

If no -main function is found, the uberjar is still created but without a main entry point.

If multiple -main functions are found, the build will fail with an error listing the conflicting namespaces. To resolve this, specify :main-ns in lib.edn:

{:name com.fooheads/example-lib
 :version "1.3.2"
 :main-ns example.core}

You can also use :main-ns to explicitly set the main namespace even when only one -main exists, or to disable auto-detection by setting it to nil.

deploy

Deploys the lib to clojars. You need CLOJARS_USERNAME and CLOJARS_PASSWORD as environment variables.

clojure -T:build deploy

Can you improve this documentation? These fine people already did:
Niclas Nilsson & Jon-Erling Dahl
Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close