lrenn/vine

clojars?

Closed this issue · 6 comments

Not really an issue, I guess, but I'd like to use the lib.

My particular use for it is that I've got an ancient app and want to write something that can compare two versions of the dependencies. Not interesting in the lein part.

Two things that would help:

  • a clojars version
  • an example of what "ivy-settings" map (I presume) should look like when you pass them in to get an "ivy" object for subsequent functions.

I'll try installing this via "lein install" in the mean time.

Thanks!

I need to update the README, but there is a version in clojars right now.

https://clojars.org/vine/vine

The code that is there is specifically written to support resolution via leiningen, but hopefully it can still be useful.

ivy-settings is not a map, but a path the to an ivy-settings file. It's done this way as I assumed most people would have an existing ivy-settings if they were already using Ivy. Let me know if I can help with your specific use case.

The resolve function returns a ResolveReport so you may be able to use that for the comparison. Again, as of now it's more a support library for a leiningen plugin but if you like more specific Ivy functionality wrapped it could be done quite easily. Just write an Issue and I'll see what I can do.

I've gotten to the point where I can read the report to get a list of files, which is all I need for my hack. However, I can't seem to get any of the dependencies. I just get the thing I named in my faked up

    :dependencies [['fake/lib "1.2+" :transitive true]]

thing. Maybe it has something to do with :conf stuff? If I use anything other than "default" the functionality breaks.

I sure hope this isn't the result of some custom back-in-the-day hackery on my colleagues part....

Humm, I'm not sure I follow. So you're saying that it resolves, but the only thing that resolves is the library itself, and not it's transitive dependencies? The :conf key should have default->someconfig.

So you're getting the list of files, do you actually want to compare something else about the dependencies? I could give you the code you're looking for if I knew exactly what you were trying to get out of the report.

So you're saying that it resolves, but the only thing that resolves is the library itself, and not it's transitive dependencies?

Yes, that's exactly what I'm saying. What I want to do is provide an artifact:

[[com.whatever/thing "1.2.3+" :transitive true]]
[[com.whatever/other "1.2.3+" :transitive true]]

and then do something like:

(defn example
  []
  (let [iv (vine/ivy-instance {:repositories repo})
        rpt (vine/ivy-resolve iv {:dependencies ideps})]
    (println "files:")
    (doseq [f (vine/report-files rpt :dependencies)]
      (println "* file: " f))))

If that worked (printed all the dependencies), I could then have everything I need to move on. ;)

I've never used ivy, so I'm sure I'm mangling the terminology.

(ns vine-demo.core
  (:require [vine.core :as vine]))

(def project {:name   "simple"
              :group   "vine.test"
              :version "0.0.1-SNAPSHOT"
              :description "Simple test project."
              :url "https://github.com/lrenn/vine"
              :dependencies '[[org.clojure/clojure "1.5.1"]
                              [ring/ring-core "1.1.8"]]})


(defn example
  []
  (let [ivy (vine/ivy-instance project)
        rpt (vine/ivy-resolve ivy project)]
    (println "files:")
    (doseq [f (vine/report-files rpt :dependencies)]
      (println "* file: " f))))
vine-demo.core> (example)
:: loading settings :: url = jar:file:/home/lrenn/.m2/repository/org/apache/ivy\
/ivy/2.3.0/ivy-2.3.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: vine.test#simple;0.0.1-SNAPSHOT
        confs: [master, default, plugins]
        found org.clojure#clojure;1.5.1 in default
        found ring#ring-core;1.1.8 in clojars
        found commons-codec#commons-codec;1.6 in public
        found commons-io#commons-io;2.1 in public
        found commons-fileupload#commons-fileupload;1.2.1 in public
        found javax.servlet#servlet-api;2.5 in public
        found clj-time#clj-time;0.3.7 in clojars
        found joda-time#joda-time;2.0 in public
:: resolution report :: resolve 331ms :: artifacts dl 11ms
        :: evicted modules:
        org.clojure#clojure;1.2.1 by [org.clojure#clojure;1.5.1] in [default]
files:
* file:  #<File /home/lrenn/.ivy2/cache/org.clojure/clojure/jars/clojure-1.5.1.jar>
* file:  #<File /home/lrenn/.ivy2/cache/ring/ring-core/jars/ring-core-1.1.8.jar>
* file:  #<File /home/lrenn/.ivy2/cache/commons-codec/commons-codec/jars/commons-codec-1.6.jar>
* file:  #<File /home/lrenn/.ivy2/cache/commons-io/commons-io/jars/commons-io-2.1.jar>
* file:  #<File /home/lrenn/.ivy2/cache/commons-fileupload/commons-fileupload/jars/commons-fileupload-1.2.1.jar>
* file:  #<File /home/lrenn/.ivy2/cache/javax.servlet/servlet-api/jars/servlet-api-2.5.jar>
* file:  #<File /home/lrenn/.ivy2/cache/clj-time/clj-time/jars/clj-time-0.3.7.jar>
* file:  #<File /home/lrenn/.ivy2/cache/joda-time/joda-time/jars/joda-time-2.0.jar>

Now I think they problem you're going to have is that your dependencies aren't in clojars or maven but in some private ivy repository at work correct? If that's the case, you'll need an ivy-settings file that properly defines the repository you want to get the dependencies from. Look for a java project that uses this repository and you should be able to find the ivysettings.xml file it's using. Then just set :ivy-settings "path/to/ivysettings.xml" into the project definition. Again, sorry, but this is all written with leiningen in mind.

I did try using our local settings file (after commenting out a lot of hokey stuff that depends on interpolated ant properties), but no go. Anyway, I'll give up for now, but thanks for your efforts, and I hope the best for your lib. Super useful. ;)