poly
Search
⌃K

Build

The Polylith tool doesn’t include a build command. That’s because we don’t want the tool to restrict our build pipeline in any way. Instead, the tool lets us choose our own way to build our Polylith artifacts for our particular pipeline; which could be with simple build scripts, all the way to cloud-based build tools.
Let's say we want to create an executable jar file out of the command-line project. Let's start by downloading build.clj and copy it to the workspace root:
example
├── build.clj
Now add the :uberjar alias to projects/command-line/deps.edn (if you followed the instructions in the tools.deps section, you have already done this):
{...
:aliases {:test {...}
:uberjar {:main se.example.cli.core}}}
Also add the :build alias to ./deps.edn:
{:aliases {...
:build {:deps {io.github.seancorfield/build-clj {:git/tag "v0.5.2" :git/sha "8f75b81088b9809ec3cfc34e951036b3975007fd"}}
:paths ["build/resources"]
:ns-default build}
Now select the build alias and refresh the IDE:
Also add "build" to Aliases in the REPL settings + restart the REPL:
The next section is only relevant if you want to learn how to configure Cursive to recognise the source code and libraries in build.clj and is not mandatory.

Configure tools.build in Cursive

Add the workspace root path to ./deps.edn:
{:aliases {:dev {:extra-paths ["."
...
Also add this library to the same file:
:extra-deps {io.github.seancorfield/build-clj {:git/tag "v0.5.2" :git/sha "8f75b81088b9809ec3cfc34e951036b3975007fd"}
...

Try it out

Let's try to build the command-line tool by executing this statement from the workspace root:
clojure -T:build uberjar :project command-line
The end of the output should say something like:
Building uberjar target/command-line.jar...
Uberjar is built.
Let's execute it:
cd projects/command-line/target
java -jar command-line.jar Lisa
Hello Lisa!
Nice, it worked!