JBoss.orgCommunity Documentation

Chapter 4. Deploying Clojure Applications

4.1. Introduction

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 $JBOSS_HOME/standalone/deployments/: 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 with the .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.

4.3. Directory-based Deployment

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 deploy 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.

4.4. Archive-based Deployment

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 archive subtask 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

The archive subtask creates the archive using the following process:

  1. The application's dependencies are resolved into the local maven repository
  2. Those resolved dependencies are copied to lib/ at the root of the project
  3. The lib/ dir is zipped up along with the src/ & resources/ dir, as well as the project.clj and immutant.clj if present at the project root.

The archive process honors the :library-path, :source-path, and :resources-path options of project.clj, allowing you to override the default directories.

Calling the archive subtask directly gives you an .ima that you can then manually deploy. To deploy an archive via the plugin, simply pass the --archive 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

If no .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.

4.5. Deployment Descriptor

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. The :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.

Immutant 0.1.0