Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to organise, test, document and package a Clojure project

I've been learning some Clojure, and I currently have a single .clj file which I edit in a text editor and which I execute on the command line.

Where can I find a guide on the practical aspects of scaling this up to larger programs/libraries?

  • How should I lay out multiple .clj files on the filesystem?
  • How should I organize and execute test code?
  • How should I document the program/library?
  • How should I package it?

I'm looking for information on the practical aspects on scaling up from small scripts to something real.

like image 830
pauldoo Avatar asked Nov 14 '10 10:11

pauldoo


3 Answers

I recommend using leiningen. Running

$ lein new myproject

will create a new folder called myproject inside your current working directory with a default skeleton structure.

Inside the newly generatedmyproject folder you'll find (among others) a folder named src for clojure source code and a folder named test for your tests (leiningen will generate a default failing test).

Leiningen will let you run your tests with lein test.

You can package your project as a jar file with lein jar or create an uberjar (an executable jar with all required dependencies included) with lein uberjar.

For generating documentation I recommend autodoc which integrates nicely with leiningen.

like image 119
mtyaka Avatar answered Sep 28 '22 05:09

mtyaka


If you are using Netbeans, there is a Clojure plugin which could be helpful to you.

Creating a Clojure project with it creates a bunch of folders: Source Packages, which contains a default package called com.yourcompany, Test Packages, Libraries, which contains the .jar for Clojure and a link to the JDK, and Test Libraries, which contains JUnit.

like image 32
Alexis Dufrenoy Avatar answered Sep 28 '22 06:09

Alexis Dufrenoy


I use a combo of:

  • Intellij Idea with the La Clojure plugin
  • Leiningen
  • Clojars
  • Midje, for testing/mocking
  • Git

Good luck!

like image 23
Alex Baranosky Avatar answered Sep 28 '22 05:09

Alex Baranosky