Fork me on GitHub
#boot
<
2017-10-11
>
lsnape09:10:39

Can anyone point me to any examples of boot tasks being tested end-to-end? I’d like to run (boot (my-task)) inside one of my tests and then check for side effects, but that understandably fails when running tests triggered by a boot test task.

richiardiandrea14:10:50

@lsnape there are examples in boot itself using boot.test give a couple of mins I can fetch one for you

phreed15:10:03

I am considering writing dynamic versions of import and require based on https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Reflector.java . The idea is to be able to pass the name of the class/method in variables; something like (import-dyn (class-name :as foo)) and static methods as (foo / method-name 5 4 3) or instance methods as (let [x (foo . 5)] (x . method-name 4 3)) where class-name and method-name are strings [require-dyn would be similar]. Has anyone already done something like this?

dominicm15:10:56

@phreed seems like a better one for #clojure

phreed16:10:24

@dominicm possibly more appropriate for #clojure but it came up while I was writing a boot task so I went with context rather than content. Specifically, it ties into writing general tasks for a code generator (antlr4) where the names of the class and methods are not known until the grammar is defined. If there are no takers here I will cross post. - https://github.com/aJchemist/boot-protobuf - https://github.com/RadicalZephyr/boot-javac-star - https://github.com/mathias/boot-sassc - etc. It would be nice if the tasks in projects like these include post-tasks that would make live coding more accessible. Here is a sample https://github.com/babeloff/boot-antlr4

cddr22:10:16

Is there a section in the docs that describe how scopes work in boot? Or is it implied from something else?

cddr22:10:43

Think I might have figured it out. It just passes through to maven right? Docs here? https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

cddr22:10:57

I've been playing around with clojure 1.9 and it's tools.deps to see how it might worth with boot. I came up with this function

(defn maven-deps
  ([]
   (maven-deps "deps.edn" [:deps] "compile"))
  
  ([deps-edn path scope]
   (let [deps (-> (slurp deps-edn)
                  (read-string))]
     (->> (get-in deps path)
          (map (fn [[k v]]
                 [k (:mvn/version v) :scope scope]))
          (into [])))))
which I can then use in my set-env! like this
(set-env!
 :resource-paths #{"src" "test"}
 :dependencies (concat (maven-deps)
                       (maven-deps "deps.edn" [:aliases :test :extra-deps]
                                   "test")))
I think that lets me specify my deps in deps.edn (for the benefit of the standard clj/clojure scripts in clojure 1.9 https://clojure.org/guides/deps_and_cli, and still use boot for build/test etc. However I'm new to boot so there might be something I'm missing.