Sorry don't know the liebke's cljr repl. But I'd like to show the
clojure 1.2 script I used to generate a `run.bat'. (I'm using windows)
======================================
(ns genrun
(:use [clojure.java.io :only (file)])
(:use [clojure.contrib.str-utils :only (str-join)]))
(def target-file (file "run.bat"))
(def current-file (file (.getAbsolutePath (file ""))))
(def jar-files
(let [d (file current-file "lib")
fs (.listFiles d)]
(filter #(re-matches #".+\.jar" (.getName %)) fs)))
(def cp
(let [get-jar-paths (fn [fs]
(reduce #(conj %1 (.getAbsolutePath %2)) []
fs))
src-path (.getAbsolutePath (file current-file "src"))
test-path (.getAbsolutePath (file current-file "test"))]
(str-join ";" (concat (get-jar-paths jar-files) (list src-path
test-path)))))
(def ret (str "@java -cp \"" cp "\" clojure.main %* & pause"))
(spit target-file ret)
======================================
You may achieve your goal by adding an `example-path'.
p.s.
I'm currently using the batch command generated by this script to
develop clojure projects.
Since I don't know how to use emacs, I guess this is the best shot I
can have, better than those plugins in eclipse and idea, I think.
On Aug 2, 5:09 am, jandot <[email protected]> wrote:
> Hi all,
>
> I'm writing a library which is organized using "lein new", so the
> directory structure contains an "src" and "test". I have added a
> directory "examples" with scripts that should be able to run by just
> typing "./example-1.clj".
>
> So the directory structure is:
> <pre>
> +- project.clj
> +- src
> | +- my-project
> | +- core.clj
> | +- io.clj
> | +- conversions.clj
> +- test
> +- examples
> +- example-1.clj
> +- example-2.clj
> </pre>
>
> Suppose that src/my-project/core.clj has the following contents:
> (ns my-project.core)
> (defn print-hello [] "Hello world")
>
> I can run that code from the repl (in my case: using liebke's "cljr
> repl") with:
> (load-file "core.clj")
> (print-hello)
>
> However, I have not been able yet to create the example script that
> should be executable by itself. What should that file look like? There
> are basically 2 issues: the she-bang line and the namespace. I've
> tried using different versions of "/usr/bin/env cljr run" and "/usr/
> bin/env java -cp cljr.jar ..." in the she-bang line, but no luck. Same
> goes for loading the my-project source files.
>
> It'll be obvious to you that I don't know java :-) Should be simple,
> but
>
> Many thanks,
> jan.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en