Skip to content
This repository has been archived by the owner on Dec 14, 2017. It is now read-only.

Project Versioning

ninjudd edited this page Sep 27, 2011 · 2 revisions

In cake, there are two different ways to specify your project version. You can specify it in the typical Leiningen style by placing it as the second argument to defproject:

(defproject foo "0.1.0" ..)

Or you can specify the project using the :version key:

(defproject foo
  :version "0.1.0")

That's nice and boring, but it isn't all that :version can do. The :version key allows for several different methods of getting the version of the project. Right now, there are two predefined methods of getting the project's version: git and hg. You can make :version use git by giving it the :git key.

(defproject foo
  :version :git)

Now, if your project is a git project, when you start cake up, it'll run git describe --tags and the output of that will be the version for your project. If you already have a project and want to try it out, you can test it by using the :version syntax above and then running cake eval '(:version cake/*project*).

Hg works similarly, but is triggered by giving :version the :hg key. It will use the last tag in the .hgtags file in your project as the version

Support for other predefined methods of calculating versions are coming soon.

Last but not least, there is also support for using your own code to calculate the version. Let's say you had some specialized way of calculating the version for your project, and wanted to write a function to do so. You could write the function, put it in project.clj, and then call that function after the :version key. Here's an example:

(defn foo [] "0.1.0") ; Overly trivial function used to demonstrate cake's awesomeness

(defproject foo
  :version ~(foo))

The above project's version would be "0.1.0", the result of calling foo. We put a tilde (~) before our code so that cake will evaluate it.