Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the version of the current clojure project in the repl

Tags:

Is it possible to grab the project information within the clojure repl?

For example, if there was a project defined:

(defproject blahproject "0.1.2" ....) 

When running a repl in the project directory, is there a function like this?

> (project-version)  ;=> 0.1.2  
like image 432
zcaudate Avatar asked Apr 29 '13 03:04

zcaudate


People also ask

How do I find Clojure version?

Just typing *clojure-version* will do the trick.

How do I get out of Clojure REPL?

You can exit the REPL by typing Ctrl+D (pressing the Ctrl and D keys at the same time).

How do I run a Clojure project?

Create a new Clojure project with Leiningen. Build the project to create an executable JAR file. Execute the JAR file. Execute code in a Clojure REPL.

What is Lein Clojure?

Leiningen is a modern build system for our Clojure projects. It's also written and configured entirely in Clojure. It works similarly to Maven, giving us a declarative configuration that describes our project, without needing to configure exact steps to be executed.


2 Answers

While you can parse project.clj yourself, this may be annoying. It's also a lot of work. Instead, you can just do:

(System/getProperty "projectname.version") 
like image 179
Paul Legato Avatar answered Sep 20 '22 15:09

Paul Legato


Leiningen project files are just Clojure data :)

(-> "/path/to/project.clj" slurp read-string (nth 2))

like image 45
deprecated Avatar answered Sep 18 '22 15:09

deprecated