I've checked in a bash script for launching Clojure to clojure-contrib/ launchers/bash/clj-env-dir.

It's configured using environment variables (one required and several optional). It sets up the CLASSPATH for the Clojure instance it launches based on the contents of a directory. This is a mechanism similar to Java's java.ext.dirs facility but implemented without using java.ext.dirs. I've tested this on Mac OS X Leopard and Ubuntu Intrepid.

Here's a description of the environment variables it uses:

# Environment variables:
#
# Required:
#
# CLOJURE_EXT The path to a directory containing (either directly or as
#               symbolic links) jar files and/or directories whose paths
#               should be included in CLASSPATH. These paths will be
#               prepended to any prior definition of the CLASSPATH
#               environment variable.
#
# Optional:
#
#  CLOJURE_JAVA The command to launch a JVM instance for Clojure
#               default: java
#               example: /usr/local/bin/java6
#
#  CLOJURE_OPTS Java options for this JVM instance
#               default:
#               example:"-Xms32M -Xmx128M -server"
#
#  CLOJURE_MAIN The Java class to launch
#               default: clojure.main
#               example: clojure.contrib.repl_ln

clj-env-dir can be used directly to launch Clojure or as a building block for creating launch scripts for a variety of purposes.

Here are two examples of using it as a building block: (these also use CLOJURE_CONTRIB whose value should be the path to an svn download directory for clojure-contrib)

"clj" (stock clojure.main call, can launch a repl, script, or just eval based on arguments to clj)

        #!/bin/bash

        export CLOJURE_MAIN=clojure.main
        CLJ=$CLOJURE_CONTRIB/launchers/bash/clj-env-dir
        OPTS=

        exec $CLJ $OPTS "$@"

"cljr" (repl using clojure.contrib.repl_ln)

        #!/bin/bash

        export CLOJURE_MAIN=clojure.contrib.repl_ln
        CLJ=$CLOJURE_CONTRIB/launchers/bash/clj-env-dir
        OPTS="--init @repl_init.clj --repl"

        exec $CLJ $OPTS "$@"

--Steve

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to