Fork me on GitHub
#boot
<
2017-05-04
>
souenzzo00:05:02

In any case, I will not have Google closure, right?

flyboarder00:05:54

@micha I found the problem with symlinks I believe!

flyboarder00:05:06

oh guess not… hmmm seems to be a problem with the visitor

flyboarder00:05:14

here is the full trace stack

danielcompton03:05:01

I'm running into an issue reloading files in Cursive using Boot: https://github.com/cursive-ide/cursive/issues/1706#issuecomment-299082525

danielcompton03:05:36

What I suspect is happening is that Cursive is saving the files to disk, and then running a clojure.tools.namespace/reload which runs against the files in the bootcache

danielcompton03:05:27

sometimes if I'm very fast, the files haven't been synced to the bootcache, and I get errors from partial files (from a previous cache) being reloaded

danielcompton03:05:55

Two questions: 1. Is this a plausible explanation 2. Is there something I/Cursive could do to tell when Boot is synced and up to date?

danielcompton03:05:24

Perhaps a blocking call in the REPL to boot to force a file sync?

danielcompton03:05:09

Possibly boot.core/sync-user-dirs!?

danielcompton03:05:18

I probably want a variant with util/with-semaphore instead of util/with-semaphore-noblock, but this is probably close enough for REPL work

martinklepsch03:05:12

(sleep 500) 😛 😄

dominicm08:05:26

@danielcompton I believe your hypothesis is correct.

berrysoup14:05:55

Hi. I found task is for modify a fileset mainly. Is it possible to create a task which will extract some information and pass the value into next task? How can I do that. I thought either about setting up additional meta of the fileset or keep the value in (atom x). I guess there in no other context stuff apart fileset.

micha14:05:20

meta on the fileset is a good way

micha14:05:28

or make a file in the fileset

micha14:05:01

using an atom is not as good because then you accumulate state by mutation rather than via immutable fileset data

berrysoup14:05:20

thanks I will try the meta case.

berrysoup15:05:47

It seems fileset made wih (with-meta fs {:version val}) is not synced properly.

berrysoup15:05:28

Can I make anonymous task? Someting relevant to (fn [] <body>) ?

micha16:05:21

@berrysoup re: the anonymous task yes, you can use the boot.core/task form

micha16:05:36

it's just the anonymous form of deftask

berrysoup16:05:08

@micha but that was stupid question. I just need to have access to TempFileSet ....

micha16:05:23

oh actually, there is no task

micha16:05:33

so please disregard that

micha16:05:41

i guess there is just no need for it, since you can do (fn [next-task] (fn [fileset] ... (next-task ...)))

micha16:05:49

^^ that's an anonymous task

berrysoup16:05:13

and I thought about (fn [] (??? (with-pass-thru fs (my-function fs arg2) )))

micha16:05:43

ah yes, the with-pass-thru just eliminates some boilerplate when you're doing a common pattern:

micha16:05:13

(fn [next-task]
  (fn [fileset]
    (.. do something here for side effects only ..)
    (next-task fileset)))

micha16:05:16

that's the same as

micha16:05:43

(with-pass-thru [fileset]
  (.. do someting here for side effects only ..))

berrysoup16:05:51

full code for that is: (deftask build-sources "Build sources jar file"

[]
  (comp
     (sift :add-resource ["src/"])
     (jar :file (format "%s-%s-sources.jar"
                        (str (name (get-env :project)))
                        (fn [nv] (core/with-pass-thru fs (apply find-version [nv fs]))) [version-ns]))
     (target)))

micha16:05:21

ah i think you might try this way:

micha16:05:01

(comp
  (sift ...)
  (jar ...)
  (with-pass-thru fs ...))

micha16:05:50

the body of with-pass-thru is only for side effects though

micha16:05:25

there is with-pre-wrap also, which is when you want the body expressions to return a new fileset to pass on to the next tasks

berrysoup16:05:46

I will convert in-body function into pre-wrap

berrysoup16:05:31

ok, Still I need to return a value in:

berrysoup16:05:39

(jar :file (format "%s-%s-sources.jar"
                        (str (name (get-env :project)))
                        (core/with-pass-thru fs (:version-sem (meta fs)))))

berrysoup16:05:54

Doesn't work

micha16:05:49

not sure what you're wanting to do there?

micha16:05:39

the jar task middleware function is what is returned when you evaluate (jar ...)

micha16:05:57

the arguments to that function are evaluated once only, when the jar task function is called

micha16:05:26

what you can do is make another task, like this

berrysoup16:05:42

OK I got:

(core/with-pass-thru fs (pp/pprint (meta fs)))

berrysoup16:05:09

The issue is I run task which keep some value in the file system metadata and now I need to get it back because I keeps a version string which should be put into jar name. 😉

berrysoup16:05:20

And the version is taken not from pom as it is in the original jar code but in dedicated namespace.

micha16:05:50

(comp
  (jar :file "project.jar")
  (with-pre-wrap fs
    (let [{:keys [version-sem project]} (meta fs)]
      (mv fs "project.jar" (format "%s-%s-sources.jar" project version-sem)))))

micha16:05:29

something like that Should Work (tm)

micha16:05:20

the issue you are having stems from the fact that tasks are created before they are composed together

micha16:05:27

like transducers

micha16:05:44

so you can't do anything in the arguments the jar function gets

micha16:05:08

because those arguments are evaluated only once when the jar task middleware is created, and before it's composed with any other tasks and before any fileset exists

micha16:05:35

the way i did it above does the renaming in the task middleware, so it has access to a fileset

micha16:05:44

and it will be evaluated every time that pipeline runs

berrysoup16:05:00

OK. I understand now.

berrysoup16:05:21

I used tasks as function but that was wrong.

micha16:05:38

yeah they're functions that return the middleware that will be used in the pipeline

micha16:05:50

the task itself doesn't do any work

micha16:05:57

it just returns the thing that will do the work later

micha16:05:30

that extra layer of indirection helps to decouple the tasks from each other

berrysoup16:05:37

thanks a lot!

flyboarder20:05:18

@micha what is the proper way to use alter-var-root to replace a task with another one?

micha20:05:40

there is the replace-task! macro for example:

micha20:05:43

boot.user=> (doc replace-task!)
-------------------------
boot.core/replace-task!
([& replacements])
Macro
  Given a number of binding form and function pairs, this macro alters the
  root bindings of task vars, replacing their values with the given functions.
  Example:
  (replace-task!
    [r repl] (fn [& xs] (apply r :port 12345 xs))
    [j jar]  (fn [& xs] (apply j :manifest {"howdy" "world"} xs)))

micha20:05:19

you probably don't need that, it's not really doing much

micha20:05:31

boot.user=> (source replace-task!)
(defmacro replace-task!
  "Given a number of binding form and function pairs, this macro alters the
  root bindings of task vars, replacing their values with the given functions.
  Example:
  (replace-task!
    [r repl] (fn [& xs] (apply r :port 12345 xs))
    [j jar]  (fn [& xs] (apply j :manifest {\"howdy\" \"world\"} xs)))"
  [& replacements]
  `(do [email protected](for [[[bind task] expr] (partition 2 replacements)]
           `(alter-var-root (var ~task) (fn [~bind] ~expr)))))

micha20:05:19

so you could do like (alter-var-root (var jar) (constantly jar2))

micha20:05:30

where jar2 is the one you want to replace it with

flyboarder20:05:46

oh cool! thats so simple 😛

micha20:05:26

(alter-var-root (var jar) (fn [old-jar] ...))

micha20:05:50

in case you want a reference to the previous value

colliderwriter20:05:41

I have a boot task whose functionality and options I'd like to make available in -main. -main is already defined using defclifn and has a few additional cli elements. How can I best do this?

dave21:05:53

AFAIK, you just have to duplicate the arguments that you want in both tasks

dave21:05:03

and pass the arguments through from one to the other

colliderwriter21:05:10

That will certainly work but was hoping for some destruct/conj magic to prevent the inevitable conflicting copies. Thanks for giving it a think.

dave21:05:24

yeah, i agree it would be nice if there were a DRYer way to do it

dave21:05:29

there might be

ag22:05:04

anyone using joker with flycheck-joker? it yells about unresolved symbols in build.boot. Following “reducing false positives” as described in the readme and adding things like deftask to .joker file not helping

ag22:05:25

I even tried specifying it like boot.core/deftask, but joker doesn’t seem to see it as boot.core thing. I tried using clojure.core/deftask hoping that would work - it didn’t