Chapter 4. Deploying Clojure Applications
Applications can be deployed to Immutant as a directory on disk, or as an
archive. The actual deployment process can be done manually or using the
lein-immutant Leiningen plugin.
See the Installation chapter for details on how to install the plugin.
4.2. Manually Deploying Artifacts
To manually deploy any artifact to Immutant, you follow the standard AS7 deployment
method. Deploying consists of creating two files in
the artifact itself, and a marker file that tells Immutant that you have
finished creating the artifact. This marker file has the same name as the artifact, but
.dodeploy suffix appended, and has no content. Example:
$ cp thing-to-deploy $JBOSS_HOME/standalone/deployments/ $ touch thing-to-deploy.dodeploy $JBOSS_HOME/standalone/deployments/
Luckily, you should rarely need to manually deploy your artifacts - the plugin takes care of that for you.
To deploy an application from where it sits on disk (in other words, without having
to create an archive), simply call the
deploy subtask of the plugin. The
subtask optionally accepts the path to the project. If no path is specified,
the current working directory is assumed:
$ lein immutant deploy # or $ lein immutant deploy path/to/project
This generates and deploys a deployment descriptor that refers to the location of the application on disk. See the descriptor section below for more details.
Immutant supports deployment of archives that have been generated by the
lein-immutant plugin. An Immutant archive is simply a zip file with a
specific format that ends with a
.ima suffix. Currently, the only supported
way to generate an Immutant archive is via the plugin. The
optionally accepts the path to the project. If no path is specified, the
current working directory is assumed. In either case, the
.ima is written to the
current working directory. Example usage:
$ lein immutant archive # or $ lein immutant archive path/to/project
archive subtask creates the archive using the following process:
- The application's dependencies are resolved into the local maven repository
- Those resolved dependencies are copied to
lib/at the root of the project
lib/dir is zipped up along with the
resources/dir, as well as the
immutant.cljif present at the project root.
The archive process honors the
project.clj, allowing you to override the default directories.
archive subtask directly gives you an
.ima that you can then
manually deploy. To deploy an archive via the plugin, simply pass the
option to the
deploy subtask. The
deploy subtask optionally accepts the path
to the project. If no path is specified, the
current working directory is assumed:
$ lein immutant deploy --archive # or $ lein immutant deploy --archive path/to/project
.ima archive exists in the current working directory, it will be generated
before being deployed.
In addition to deploying an
.ima directly, you can also manually deploy a
deployment descriptor that refers to the location of the archive. See the
descriptor section below for more details.
An Immutant deployment descriptor is simply a Clojure file containing a map of
options. When a descriptor is deployed, Immutant reads the file in and uses it
to determine where the actual application resides by looking at its
:root entry can either be the path to the application root on disk,
or the path to an
.ima archive. For details on the format of the deployment
descriptor, see Configuration Options.