Fork me on GitHub
#beginners
<
2015-07-23
>
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.

robert-stuttaford10:07:39

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

robert-stuttaford10:07:02

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

robert-stuttaford10:07:15

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

tap13:07:27

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

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

surreal.analysis14:07:07

@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

surreal.analysis14:07:48

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

tap14:07:24

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.

robert-stuttaford15:07:05

nothing wrong with what you have

kamn15:07:28

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?

surreal.analysis17:07:50

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

surreal.analysis17:07:48

But, I believe you can also use :resource-paths [“path/to/jars/“] based on the bottom of this: https://github.com/technomancy/leiningen/issues/1063

kamn17:07:03

@surreal.analysis: Thanks for the feedback!

kamn17:07:31

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

curtosis17:07:35

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

curtosis17:07:16

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

curtosis17:07:29

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

curtosis17:07:58

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

curtosis17:07:03

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

curtosis17:07:03

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

kamn17:07:10

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

curtosis17:07:46

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

kamn17:07:00

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

curtosis17:07:42

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.

curtosis17:07:12

a little extra discipline saves a lot of headache.

curtosis20:07:10

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.

kamn22:07:51

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