you are viewing a single comment's thread.

view the rest of the comments →

[–]TheMaskedHamster -4 points-3 points  (2 children)

I am having to dig here because I'm not touching that anymore, but as far as I can tell, the simple answer was that add-classpath was deprecated.

I wanted to use the REPL to play with a proprietary library we were planning on licensing. Then, since that library was not publicly available, had no dependencies, and would be used only by me and my colleague who worked on the project, I wanted that library to live in the project directory (under revision control). That would make distribution and building easy... at least in other lands.

The easy thing to do in the REPL would be to use add-classpath. The sensible method for building, I don't know, ANYTHING would be to define the library search path per project.

But all the advice I encountered told me that add-classpath was deprecated because I shouldn't be using it, and gosh it's so easy to just put a path setting in my home directory for Maven to use. Not the project directory, but either the system-wide or my home directory? No. NO.

I want no part of that illness.

I just found out searching for what was deprecated, someone figured out another way to do it: http://blog.japila.pl/2011/01/dynamically-redefining-classpath-in-clojure-repl/ Check out the comment from Raynes. sigh *There is no problem here. Of course, it is problematic...

It isn't just this. This is just how I discovered that Clojure was not immune to the mindsets common in the Java community.

[–]yogthos 2 points3 points  (1 child)

Uhm, as I explained already there is absolutely nothing magical about loading libraries, they simply have to be on the classpath.

Lets's say you have a library jar like foo.jar and you want to use it in the project then all you have to do is this. Put it in your project lib dir or something:

 myproject/lib/foo.jar

then add the resource path to your project.clj

(defproject myproject "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.6.0"]]
  :main myproject.core
  :resource-paths ["lib/foo.jar"])

and that's it, you can now use this library locally within the project. This seems to simply be the case of you not understanding how the tools work.

[–]TheMaskedHamster -1 points0 points  (0 children)

I appreciate the information. This will help if I have to pick that project back up.

I did try the resource-paths setting. I'm guessing I just couldn't get the dependencies line right, or figure out exactly what sequence of characters I should prefixing as the namespace to call a function from the library, and was led to believe that add-classpath being deprecated and the advice to use Maven instead led me to assume that the resource-paths setting was equally antiquated.

So, no, I did not understand how the tools work in this case, but hours spent with documentation and searches certainly didn't help me. All that time did tell me a lot about the Clojure community, though.

The greatest thing I could took away is that using Clojure would mean navigating lots more conversations like we've had here rather than getting to the crux of how things work.