poly
Search…
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:
1
example
2
├── build.clj
Copied!
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):
1
{...
2
:aliases {:test {...}
3
:uberjar {:main se.example.cli.core}}}
Copied!
Also add the :build alias to ./deps.edn:
1
{:aliases {...
2
:build {:deps {io.github.seancorfield/build-clj {:git/tag "v0.5.2" :git/sha "8f75b81088b9809ec3cfc34e951036b3975007fd"}}
3
:paths ["build/resources"]
4
:ns-default build}
Copied!
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:
1
{:aliases {:dev {:extra-paths ["."
2
...
Copied!
Also add this library to the same file:
1
:extra-deps {io.github.seancorfield/build-clj {:git/tag "v0.5.2" :git/sha "8f75b81088b9809ec3cfc34e951036b3975007fd"}
2
...
3
Copied!

Try it out

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