Fork me on GitHub
#boot
<
2017-07-18
>
dm306:07:59

@xiongtx java task will compile whatever java sourcefiles it finds in the fileset with the input roles - namely files in :source-paths and :resource-paths

xiongtx18:07:51

dm3: Does the java task need to be invoked explicitly? Or is this sufficent? https://github.com/alandipert/boot-java-task-example/blob/master/build.boot#L1

alandipert18:07:32

@xiongtx check out the readme, i’m invoking explicitly from CLI

alandipert18:07:46

javac that is

dm306:07:48

@freakinruben you need to commit! the fileset after changing it and then return from a with-pre-wrap handler so that the following tasks can work with a changed fileset. sift is the task that does exactly that if you compose it properly, e.g.:

(comp (do-something) (sift ...) (do-with-moved-files))

Ruben W07:07:39

@dm3 I saw that (target) (which is called after sift) commits, is it still required to commit! in my own task too? Because the task thats called after moving (compile clj) needs the original inputfiles and not the moved fileset..

(deftask move ...)
(deftask a (comp (cljs) (move)))
(deftask b (comp (system) (repl)))
(deftask c (comp (a) (b)))

dm309:07:39

@freakinruben not sure if you’ve read this part of the wiki: https://github.com/boot-clj/boot/wiki/Filesets#the-task-model. The fileset is a snapshot of your files that every task receives from the task before it and returns to the next task in the chain. It’s effectively an immutable value.

dm309:07:48

if you want to “modify” a fileset, you need to commit, otherwise your changes will not be seen by the other tasks

maleghast10:07:34

Hello All - I’ve tried a quick Google, but to no avail… I have an nrepl running on 127.0.0.1:5601 - how would I use boot to launch a command line REPL to connect to that nrepl..?

dm310:07:05

boot repl -c -p $PORT I think… In general boot has good help for every task with boot $TASK -h

sekao14:07:20

is it possible for a boot script to run another boot script in the same JVM instance?

dave14:07:44

@sekao would (load-file "foo.boot") work?

sekao14:07:27

@dave didn't think to try that, thanks!

dave14:07:59

the only thing i could see potentially being an issue with that is that if the script you're loading has (set-env! :dependencies '[[ .... ]]), it might have some weird effect on the dependencies

dave14:07:04

merge-env! can solve that

ag17:07:46

what's the idiomatic way to ensure that a dependency added only for when $DEV=true, so the lib is not added to the production CLJS bundle ?

ag17:07:59

should I use (merge-env! :dependencies ,,, etc.]) and do it in my dev-env task?

ag17:07:29

but then the Clojurescript code that tries to require it will throw an exception

ag17:07:32

I can't just leave it there and hope that cljs compiler's dead-code elimination would remove it and won't bundle for prod, since the check happens at runtime

martinklepsch17:07:50

@ag which check happens at run time?

ag17:07:43

there isn't something like lein profiles in boot, right?

ag17:07:19

so I'm struggling to find a way to have different cljs dependencies for dev and prod builds

ag18:07:16

for example if I have a dependency let's say [binaryage/devtools "0.9.4"], and I want this thing only be included to dev build (e.g. for when $DEV=true. How do I do that?

ag18:07:52

I can probably use a task like this:

(deftask dev-env  []
  (merge-env! :dependencies '[[binaryage/devtools "0.9.4"]])
  (environ :env ,,, ; etc
but then how do I make sure the Clojurescript code that requires devtools.core doesn't throw exceptions when running on prod?

ag18:07:58

I guess the only viable way to solve this is by using different edn files and different cljs ids, amright?

alandipert18:07:47

(def deps
  (case (.toLowerCase (System/getenv "DEPLOY_ENV"))
    "prod" prod-deps
    "dev" dev-deps
    dev-deps))

(set-env! :dependencies deps)
is one way

alandipert18:07:49

then to ensure your prod build doesn’t throw exceptions… test locally 😄

ag18:07:00

can someone point to an example with multiple "profiles"/edn files? I think I almost got it. Having trouble with the correct naming of things

ag18:07:07

one thing I can't figure out when using (cljs :ids #{"js/dev"}) with js/dev.cljs.edn, how to ensure that it ends up compiling to main.js and not dev.js?

ag18:07:35

also I feel that compiler-options not being picked up when put in .edn file. seems :verbose true for example is being ignored (when it's in edn), but works when passed into the cljs task directly

pandeiro19:07:31

@ag An easy way to do it is to have env/dev/src/main.cljs.edn and env/prod/src/main.cljs.edn, and include the former in your dev task and the latter in your build task

ag19:07:30

I'll try that. Thanks

ag20:07:17

but then cljs puts it in target/env/dev/main.js . can I force it to put it in target/js/main.js ?

ag20:07:58

me trying :output-to "js/main.js"

ag20:07:29

it didn't work 😞

ag20:07:35

me: trying :output-dir

pandeiro20:07:37

So no, actually you would include that entire path in your src-paths

pandeiro20:07:59

So it would appear relative to the src dir

pandeiro20:07:48

(deftask dev
  []
  (merge-env! :source-paths #{"env/dev/src"})
  ...)

ag20:07:05

so I wouldn't have to use (cljs :ids ?

pandeiro20:07:25

No need, you would just be using the main.cljs.edn always

pandeiro20:07:48

Which would live in env-specific src dir

ag21:07:55

still can't make it work ;(

ag21:07:34

do you have example project?

ag21:07:59

I'm hitting an exception: java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.Symbol

pandeiro22:07:13

Sorry, no example readily available - if you show me yours though, I might be able to help

ag22:07:22

it's not an open-source project. Let me play with things here, If I fail to make it work I will try to replicate in a sample project

ag22:07:55

sigh... boot is so amazing... until something like this hits you in the face ;(

ag20:07:54

sigh... multiple builds with boot-cljs seems not straightforward to get. so is :output-to and :output-dir of compiler-options are ignored and precise path+filename is fully determined by the edn file?

ag20:07:32

that's so awfully inconvenient

ag20:07:02

what's :unified-mode ?

ag21:07:55

goddamit... can't make it work. so there's no way to force compiled cljs files to be in the right place, i.e. force it to respect :output-dir or/and :output-to ?

pandeiro22:07:49

It will just output to the same location that it is found in src

pandeiro22:07:02

src/main.cljs.edn => target/main.js

pandeiro22:07:45

If you are serving resources from the classpath, your HTML should be able to include a <script src="main.js"></script> and it will just work

pandeiro22:07:02

So what I was telling you above is, you would not have any src/main.cljs.edn, but instead would put different ones in env/dev/src/main.cljs.edn and env/prod/src/main.cljs.edn, for example, and make sure the right source-paths are included for each task

pandeiro22:07:00

The env/dev/... one could point to a namespace like myapp.core-dev, which would call your myapp.core/init, but also bring in things like binaryage/cljs-devtools, additional logging, etc

pandeiro22:07:20

Does that make sense @ag?

ag22:07:10

It does... but I can't make it work ;(

ag22:07:26

something's not right

ag22:07:02

It was painful but I think I made it work... I had to put logic to pick up specific js file in my index page (based on the build)

ag23:07:04

@pandeiro could it be that for some reason if I put :compiler-options to edn file they are ignored, but when they are passed to cljs task they are not? Or am I doing something wrong?

pandeiro23:07:48

I have never put them in the edn file, not sure if it is supposed to work that way

ag23:07:01

samples show that it supposed to, I guess I just do it in the task

ag23:07:08

Thanks!