Liking cljdoc? Tell your friends :D

Build

The poly tool doesn’t include any build commands. That’s because we don’t want poly to restrict your build pipeline in any way. Instead, poly lets you choose how to build your deployable artifacts for your particular pipeline. Whether you choose simple build scripts or cloud-based build tools, poly doesn’t get in the way.

Let’s continue with our tutorial. The last thing you did was create a command-line project. Let’s add build support to create an executable jar file for the command-line project.

Per its philosophy, you’ll notice that poly did not generate any build scripts for your example workspace.

We’ll be using Clojure tools.build to build your jar. This is a common choice for tools.deps projects. We’ve created a sample build.clj for you. Copy it to your example workspace root:

example
├── build.clj
...

Add the uberjar configuration expected by our build.clj to your command-line project by adding :uberjar alias to projects/command-line/deps.edn:

{:deps {poly/user {:local/root "../../components/user"}
        poly/cli  {:local/root "../../bases/cli"}

        org.clojure/clojure {:mvn/version "1.11.1"}}

 :aliases {:test {:extra-paths []
                  :extra-deps  {}}

           :uberjar {:main se.example.cli.core}}} (1)
1Add :uberjar alias describing the main entry point

Add a :build alias to your ./deps.edn:

{:aliases {...
           :build {:deps {io.github.clojure/tools.build {:mvn/version "0.9.6"} (1)
                          org.clojure/tools.deps {:mvn/version "0.16.1281"}}  (2)
                   :paths ["build/resources"] (3)
                   :ns-default build} (4)
1Clojure tools.build support
2Our build.clj happens to use tools.deps
3An example of adding some resources to our classpath
4Points to our build.clj

Cursive Users: Select the build alias and refresh the IDE:

aliases

Add build to Options in the REPL settings + restart the REPL:

add build to repl settings

Older Versions of Cursive

If you are still using Cursive pre v1.13.0 we recommend that you upgrade.

If you are unable to upgrade, you’ll need to set Options to dev,test,build instead.

You may also need to add the workspace root dir to your paths in your ./deps.edn if the IDE doesn’t recognize build.clj as source code:

{:aliases  {...
            :build {...
                    :extra-paths ["."] (1)
1Add workspace root dir to paths if necessary

Try it out

Now that you have everything set up, build the command-line jar by executing the following from the example workspace root dir:

clojure -T:build uberjar :project command-line

You should see some output:

Compiling se.example.cli.core...
Building uberjar target/command-line.jar...
Uberjar is built.

Congratulations! You’ve just built your first artifact from a deployable project. Try running it:

cd projects/command-line/target
java -jar command-line.jar Lisa
Hello Lisa!

Nice, it worked!

Can you improve this documentation?Edit on GitHub

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

× close