Ok,

So I'm trying to write a leiningen plugin that takes some namespace
arguments. Let's call it *<myplugin>*. This is a brand new plugin, so
everything else is empty, and this value is present: *{:eval-in-leiningen
true}*. My problem happens when, in the context of the project *<myplugin>*
is acting on, the plugin code fails. I pass in some project-local namespace
that I want to eval (which is definitely present). And I get this
situation:

*Error*

java.lang.Exception: No namespace: <mynamespace> found


*Offending Code*

(defn check-foreach-namespace [namespaces]


  (let [fnss (filter #(= Fubar (type (var-get %)))

                     (vals *(ns-publics (symbol (first namespaces)))*))]


    (println "filtered-namespace [" fnss "]")))


(defn myplugin [project & args]

  (check-foreach-namespace args))



So then, if I try to require the namespace being passed in, that too fails
like so:

*Error: *

java.io.FileNotFoundException: Could not locate <mynamespace_file.clj> on
classpath:


*Offending Code:*

(ns leiningen.chesk

  (:require [clojure.test.check :as tc]

            [clojure.test.check.generators :as gen]

            [clojure.test.check.properties :as prop]))


(defn check-foreach-namespace [namespaces]



  (let [nss (map *#(require (symbol %))* namespaces)

         fnss (filter #(= clojure.test.check.generators.Generator (type
(var-get %)))

                     (vals (ns-publics (symbol (first nss)))))]


    (println "filtered-namespace [" fnss "]")))


(defn myplugin [project & args]

  (check-foreach-namespace args))


Looking around, I thought I had found some relevant instruction on how to
handle this gilardi scenario
<https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md#evaluating-in-project-context>.
So I tried to use *eval-in-project* with and without namespace prefix, and
with several permutations of quoting. This is the error that occurs.

*Error: *

clojure.lang.Compiler$CompilerException: java.lang.ClassNotFoundException:
leiningen.core.eval


*Offending Code: *

(ns leiningen.chesk
  (:require [clojure.test.check :as tc]
            [clojure.test.check.generators :as gen]
            [clojure.test.check.properties :as prop]))

(defn check-foreach-namespace [namespaces]

  (let [fnss (filter #(= clojure.test.check.generators.Generator (type
(var-get %)))
                     (vals (ns-publics (symbol (first namespaces)))))]

    (println "filtered-namespace [" fnss "]")))

(defn myplugin [project & args]
  (*leiningen.core.eval/eval-in-project* project
                                       (check-foreach-namespace args)
                                       (map #(require (symbol %)) args)))




So something that looks like it should be straightforward, is not working
out as planned. I also can't quite see how other plugins are doing this.
lein-midje seems a bit cryptic (see here
<https://github.com/marick/lein-midje/blob/master/src/leiningen/midje.clj#L14-L23>
and here
<https://github.com/marick/Midje/blob/master/src/midje/repl.clj#L192-L235>).
Are there any clearer examples?


Tim Washington
Interruptsoftware.com <http://interruptsoftware.com>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to