Skip to content
ninjudd edited this page Aug 24, 2010 · 6 revisions

Default Tasks

see: Default Tasks

Creating tasks in your project.clj:

This is the easiest method. Your project.clj with a cake task should look like this:

(defproject project "0.0.0-SNAPSHOT"
  :description "TODO: add summary of your project"
  :dependencies [[clojure "1.2.0-master-SNAPSHOT"]])

(deftask hello-world []
  (println "Hello world."))

You can also put tasks in build.clj, which allows you to maintain Leiningen compatibility.

Creating tasks in another project file:

Given a directory structure which looks like this:

~/project
├── ./LICENSE
├── ./build
├── ./classes
├── ./lib
│   └── ./lib/clojure-1.2.0-master-20100727.210144-91.jar
├── ./pom.xml
├── ./project.clj
├── ./src
│   └── ./src/project
│       ├── ./src/project/core.clj
│       └── ./src/project/tasks.clj
└── ./test

And a project.clj which looks like this:

(defproject project "0.0.0-SNAPSHOT"
  :description "TODO: add summary of your project"
  :dependencies [[clojure "1.2.0-master-SNAPSHOT"]]
  :tasks [project.tasks])

And a tasks.clj which looks like this:

(ns project.tasks
  (:use cake.core))

(deftask hello-world []
  "This is an example task located in another file."
  (println "Hello, world."))

Clone this wiki locally