Fork me on GitHub
Petrus Theron09:07:55

I need to use a particular branch of a library that is currently on clojars (clj-rethinkdb in this case). How should I go about including this branch of a library as a dependency in my project? Do I need to compile it from source, which raises questions about git submodules and where to put it. I presume I can add it to my local maven repo somehow, but I have never done this before.


clone the git project, switch to the branch, lein install. match the project.clj version in your code. you’re done


lein install will place a compiled jar for the project you’re in into your local maven repo


which is where lein looks for deps before downloading them from e.g. clojars


In condp, how to specify result-fn for the else clause? This causes IllegalArgumentException

(condp #(%1 %2) {:c 5}
  :a :>> inc
  :b :>> dec
  :>> #(* 5 %))


@tap: What do you expect to be returned from that function? (* 5 {:c 5} )? If that’s the case, I don’t think it makes sense to use the result function, but rather just a separate function call the way you would normally use else. For example

(let [parameter {:c 5}]
  (condp #(%1 %2) parameter
    :a :>> inc
    :b :>> dec
    (keys parameter))) ;; Used this as the original doesn’t work


The main issue is that result-fn gets applied to the result of the predicate, and in this case you do not have a result of the predicate, because you do not want to give it 2 arguments


thanks @surreal.analysis. I’m doing it that way as well.

Petrus Theron15:07:51

What's the shortest way to turn {:cheque "Cheque", :savings "Savings"} into [{:id :cheque :label "Cheque"} {:id :savings :label "Savings]?

Petrus Theron15:07:21

Right now I have, (map (fn [[k v]] {:id k :label v} my-map), but it feels like I could use a zipmap or something to make it even tighter.


nothing wrong with what you have


I have a lein question. If I want to include a .jar into a project do I have to setup a local maven repo? Or is there some other way?


@kamn: I typically use lein localrepo, which does interact with the local maven repo


But, I believe you can also use :resource-paths [“path/to/jars/“] based on the bottom of this:


@surreal.analysis: Thanks for the feedback!


I will have to play with the resource path option. I was just setting up a cljsjs package and wanted to tested out. Seems like a good option


yes, I think we had a related conversation in another channel recently (that I can't find because search limits)


my recommendation is: - for artifacts YOU generate (e.g. in other projects) use a local repo - for unpublished third-party things you depend on, :resource-paths is ok, when a local repo doesn't make sense


my current project has both: two unpublished 3rd-party jars, and 2GB worth of parser models and such


the jars are in a local repo, and the models are in a separate directory pulled in via :resource-paths


I also set up & check in my local-repo directory as part of the project.


that part's iffy, but keeps the dependency structure clear and consistent.


That leads me to another question but lets say I have reagent and my-proj. I want to change functionality in the regeant project and test it in my-proj


then you should probably use a local repo external to both projects.


hmm I thought I remember reading something about using libs folder path and symlinking once but that might of been for lein 1.x not lein 2.x


there are ways you could force it to work, but the likelihood of it ending in tears down the road (under pressure, usually) is very high.


a little extra discipline saves a lot of headache.


I haven't used checkouts, but it looks like they solve a different problem: it just makes source changes visible in a different project. Based on my quick scan of the docs, you still have to list it in :dependencies and make the library lein-findable.


You are right. It would not solve my original problem.