Declare App Dependencies

Page last updated:

Page last updated:

Cloud Foundry uses the Java buildpack to execute the uploaded JAR file as application package. The Java buildpack will run your application using the main() method from the core.clj file.

The dependencies needed for the application are stored in the project.clj file and are included in the standalone JAR during the compilaton phase. When you create a new project with Leiningen, the file project.clj is created automatically. To add new dependencies to the project, simply modifiy the file accordingly.

The demo app you deployed already has a project.clj, and it looks something like this:

(defproject cf-sample-app-clojure "0.1.0-SNAPSHOT"
  :description "Sample Clojure application for Cloud Foundry"

  ...

  :dependencies [[org.clojure/clojure "1.8.0"]
                 [compojure "1.5.1"]
                 [ring/ring-defaults "0.2.1"]
                 [ring/ring-jetty-adapter "1.5.0"]
                 [hiccup "1.0.5"]]

  ...

  :main cf-sample-app-clojure.core
  :aot [cf-sample-app-clojure.core])

The project.clj file determines both the version of Clojure that will be used to run your application on Cloud Foundry, as well as the dependencies that should be installed with your application.

To install the dependencies, compile the project with:

$ lein uberjar
2016-04-05 09:41:09.060:INFO::main: Logging initialized @3611ms
Compiling cf-sample-app-clojure.core
Created /.../cf-sample-app-clojure/target/cf-sample-app-clojure-0.1.0-SNAPSHOT.jar
Created /.../cf-sample-app-clojure/target/cf-sample-app-clojure-0.1.0-SNAPSHOT-standalone.jar
I’ve installed the App dependencies locally
View the source for this page in GitHub