[Cs254f11] Libraries and documentation

Lee Spector lspector at hampshire.edu
Sun Sep 25 15:49:25 EDT 2011


Nathan,

I've been looking for and nudging some developers for good general documentation of this too, especially in conjunction with a clooj-based workflow.

But in the meantime here's a description of a process that should work in many cases. Here I'll describe how to install and test clj-processing (which lets you use the Processing libraries in Clojure):

- First make sure you have leiningen installed. It should already be installed correctly on all of the machines in ASH 126. To install it on your own machine go to https://github.com/technomancy/leiningen and follow the instructions in the "Installation" section. You don't have to download the whole project -- just the one shell script file linked in the Installation section. If it's installed correctly then the command "lein" (with no quotes) at a shell prompt should give you some information about all of the tasks you can run with leiningen… but we'll use just one of them, below. 

- Edit your project's project.clj file to include the following, which is the information for the clj-processing library (and which I obtained from the clj-processing documentation) in the vector of dependencies:

    [org.clojars.automata/rosado.processing "1.1.0"]

- In an OS command shell (e.g. in Terminal in Mac OS X) change directories until you're in your project's directory (able to see project.clj if you list the directory contents).

- Enter the command "lein deps". What this does (if all goes well) is to retrieve the actual library code and install it into the right places in the project. (For some libraries other steps may be required here too, e.g. maybe "lein compile", but all you need to do for this example is "lein deps". If other steps are required then they *should* be documented by the library's authors.)

- Unfortunately, clooj may not yet know that the library is there (or rather it may see it but not have it on the classpath), so: Quit and restart clooj (which will make sure that it sees everything when it restarts).

- Write some code in one of your project's files that uses/tests the library. In this case I just copied everything from https://github.com/rosado/clj-processing/blob/master/examples/example2.clj and changed only the name of the namespace to match my file name (which is not strictly necessary here, but the namespace and file name should generally match). Then I run that code (command-E in clooj) and I get a little window with a colorful diamond. (Note that this particular library/example has the odd property that if you click the close button on the graphics window it not only closes the window but also quits clooj. But you can instead type (stop example2) in the REPL to close the window without leaving clooj.)

Working with most other libraries should be MOSTLY the same, but over the handful of libraries that I've played with I've seen a few somewhat different setups. If you can do the above, however, and see how most of the parts work, then you should be able to navigate some of the variations (and ask here if not).

 -Lee



On Sep 25, 2011, at 2:53 PM, Nathan Winter Whitmore wrote:

> 
> 
> Hey all,
> 
> Does anyone know of any Clojure documentation that clearly explains the process
> of installing a library using lein?
> 
> Thanks,
> Nathan
> _______________________________________________
> Cs254f11 mailing list
> Cs254f11 at lists.hampshire.edu
> https://lists.hampshire.edu/mailman/listinfo/cs254f11

--
Lee Spector, Professor of Computer Science
Cognitive Science, Hampshire College
893 West Street, Amherst, MA 01002-3359
lspector at hampshire.edu, http://hampshire.edu/lspector/
Phone: 413-559-5352, Fax: 413-559-5438



More information about the Cs254f11 mailing list