So here are my questions:
Am I going about this the wrong way? Is there an easier way to explore
existing open-source projects? I
Is there a less cumbersome way to get a load of files on the classpath
than manually editing the .clojure file?
How do I tell the REPL where to find response.clj so that core.clj
will load?
Any other advice will be much appreciated as well.
Thanks,
Daniel
Well, I have a ~/lib/clojure directory and a clj script that
automatically puts that directory and all .jar's in it on the
classpath. Linux version:
#!/bin/bash
: "${CLOJURE_LIB:=${HOME}/lib/clojure}"
export CLASSPATH="${CLASSPATH:+$CLASSPATH:}$HOME/lib/java/clojure.jar:$CLOJURE_LIB"
if [ -d "$CLOJURE_LIB" ]; then
for f in "$CLOJURE_LIB"/*.jar; do
if [ -r "$f" ]; then
CLASSPATH="$CLASSPATH:$f"
fi
done
fi
rlwrap java clojure.main "$@"
The actual java invocation can of course be replaced to e.g. use JLine
instead of rlwrap; I use the latter because JLine doesn't seem to have
a vi mode. (Yes, I know, vi user in a Lispy language - heretical!)
--
Mark J. Reed <mark...@gmail.com>
> Am I going about this the wrong way? Is there an easier way to explore
> existing open-source projects? I
Try this for any leiningen project (check for the existence of a
project.clj file). I'm assuming you're using a unixy operating system.
First and once-off, install leiningen:
wget http://github.com/technomancy/leiningen/raw/stable/bin/lein
chmod a+x lein
./lein self-install
Clone target project (in this case Compojure):
git clone git://github.com/weavejester/compojure.git
cd compojure
Ask Lein to download Compojure's dependencies (this includes Clojure,
you don't need to it install it manually):
../lein deps
Fire up a repl:
../lein repl
Clojure 1.1.0
user=> (use 'compojure.core)
nil
Alternatively if you're using Java 6 you can start the REPL without any
wrapper script pretty easily. I prefer to do it this way as it makes it
obvious what the classpath is and allows tweaking the JVM options (for
example increasing the memory limit with -Xmx256m).
java -cp 'lib/*:classes:src' clojure.main
Clojure 1.1.0
user=> (use 'compojure.core)
nil
> Is there a less cumbersome way to get a load of files on the classpath
> than manually editing the .clojure file?
Note the wildcard 'lib/*' notation I used above. This was added in Java
6. Be aware that it has to be some/directory/* not *.jar, foo* or any
other variation. Put it in single quotes to make sure your shell
doesn't try and expand it. It'll add any jar files found in the
directory to the classpath.
Hope that helps.
Alex
For Compojure I think you need also Ring: http://github.com/mmcgrana/ring
(also a mailing list here: http://groups.google.com/group/ring-clojure)
There's been a lot of activity there recently, various projects
refactoring in terms of each other, and that seems to be where
they're ending up. I don't know too much about it, but I did run
through the code and examples just yesterday.
The other thing is: leiningen. http://github.com/technomancy/leiningen
A lot of projects are using it, and it's dead simple dependency management.
Download the project, look for the project.clj file, run 'lein deps'
in that directory, and you get all needed dependency jars loaded into
a 'lib' subdirectory.
cheers,
Kevin Kelley
-SS
On Mar 30, 3:45 pm, Stuart Sierra <the.stuart.sie...@gmail.com> wrote:
> Take a look at the dependency management tools. Most open-source
> Clojure projects use either Maven and Leiningen. Both use the same
> dependency model and provide similar capabilities for starting a REPL
> with the classpath configured automatically.
There are also gradle and ant combined with Ivy as possible helpers.
They also build on the maven repositories. So they should work fine,
too.
Sincerely
Meikel
To start a hello world app:
1. Download conjure.jar from: http://github.com/macourtney/Conjure/downloads
2. java -jar conjure.jar hello_world
3. cd hello_world
4. ./run.sh script/server.clj
5. Point your browser at http://localhost:8080/
6. Profit!
There is a tutorial for Conjure at: http://wiki.github.com/macourtney/Conjure/hello-world-tutorial-2
-Matt Courtney
Thanks,
Daniel
On Mar 30, 6:50 pm, Matt <macourt...@gmail.com> wrote:
> If you're not stuck on using Compojure, you can try Conjure which will
> includes all of the dependencies in the jar.
>
> To start a hello world app:
>
> 1. Download conjure.jar from:http://github.com/macourtney/Conjure/downloads
> 2. java -jar conjure.jar hello_world
> 3. cd hello_world
> 4. ./run.sh script/server.clj
> 5. Point your browser athttp://localhost:8080/
Thanks for all the quick replies. I should've mentioned that I'm
already using leiningen, so the problem isn't so much getting the
dependencies and building the application as it is figuring out a way
to get inside the code and play with it a bit. I'd like to be able to
load the source files, execute member functions, and just get a feel
for what's going on internally. What sort of method do you all use for
exploring open source projects? Do you just read the source code, or
do you load it and test it out?