There are two kinds of projects
in Polylith: development and deployable.
The development project:
-
Where you work with the code, often from a REPL.
-
Described in
./deps.edn
which:-
Specifies all bricks and project libraries used by the project.
-
Optionally defines profiles.
-
-
Source code to support development (not part of any component or base) lives under the
./development
directory.
A deployable project:
-
Used to build deployable artifacts, e.g., lambda functions, REST APIs, tools, etc.
-
Has its own directory under the
./projects
directory (e.g.,my-project
), which:-
Has a
deps.edn
specifying the bricks and libraries used by the deployable project.-
If the referenced bricks contain any tests, they are run when you execute the test command.
-
-
Can optionally have a
resources
directory. -
Can optionally have a
test
directory for project-specific tests. -
Doesn’t have a
src
directory. We discourage asrc
directory for deployable projects; all production code should normally only live in bricks.
-
The :project
key in ./workspace.edn
configures project aliases and, optionally, how poly
should run your tests.
Let’s continue with our tutorial.
The last thing you did was create a cli
base.
Run the following create project command:
poly create project name:command-line
Your workspace should now look like this:
example
├── bases
│ └── cli
│ ├── deps.edn
│ ├── resources
│ │ └── cli
│ ├── src
│ │ └── se
│ │ └── example
│ │ └── cli
│ │ └── core.clj
│ └── test
│ └── se
│ └── example
│ └── cli
│ └── core_test.clj
├── components
│ └── user
│ ├── deps.edn
│ ├── resources
│ │ └── user
│ ├── src
│ │ └── se
│ │ └── example
│ │ └── user
│ │ ├── core.clj
│ │ └── interface.clj
│ └── test
│ └── se
│ └── example
│ └── user
│ └── interface_test.clj
├── deps.edn
├── development
│ └── src
│ └── dev
│ └── lisa.clj
├── logo.png
├── projects
│ └── command-line # (1)
│ └── deps.edn
├── readme.md
└── workspace.edn
-
new
command-line
project
The poly
tool helpfully reminds us:
It's recommended to add an alias to :projects in ./workspace.edn for the command-line project.
If you don’t follow this advice, the command-line
project heading will default to ?1
when running the info command.
Go ahead and add an alias in your ./workspace.edn
:
{...
:projects {"development" {:alias "dev"}
"command-line" {:alias "cl"}}} (1)
-
Add the
cl
alias
for thecommand-line
project
Add the user
component and the cli
base to your new project by editing projects/command-line/deps.edn
:
{:deps {poly/user {:local/root "../../components/user"} ;; (1)
poly/cli {:local/root "../../bases/cli"} ;; (2)
org.clojure/clojure {:mvn/version "1.11.1"}}
-
Add
user
component -
Add
cli
base
The :local/root
paths begin with ../../
because the components
and bases
directories are two levels up relative to projects/command-line
directory.
When you run the test command, poly
will determine which tests should run.
If you want to run tests for each deployable project outside of poly
using Clojure’s tools.deps, you must specify the test paths in your ./deps.edn
.
Note
|
Each But Clojure’s tools.deps does not include test dependencies from |
Where you specify dependency to bricks differs based on the project type:
-
For the development project:
./deps.edn > :aliases > :dev > :extra-deps
-
For deployable projects:
./projects/PROJECT-DIR/deps.edn > :deps