Fork me on GitHub
#boot
<
2018-02-04
>
candera13:02:12

I’m building an electron app with hoplon/boot. Works great. But it would be nice to have source maps so I don’t have to work my poor tiny brain so hard to figure out where my exceptions are coming from. Currently, my .js.map files have source paths in them like "mission.html.out\/weathergen\/ui.cljs". Probably because of something to do with the fairly complicated setup involved in getting an Electron app working, this is incorrect. It should instead be simply "ui.cljs". It’s easy enough to write a task to rewrite these guys, but it’s not working. I think I’m doing something wrong with the Boot fileset stuff, where the modified file is not getting added to the output. I.e. when I look at the resulting .js.map files in the target directory, they still have the incorrect path, even though debug output in my task shows me that they should be getting rewritten correctly. I imagine I’m making some rookie mistake with tasks/filesets. Any idea what it might be?

candera13:02:47

OK, was missing a with-open on the writer, but that didn’t fix the problem. I can see that the temp output directory contains the correct file. It just doesn’t wind up making its way into the target folder.

nha14:02:47

I have a CLJ program that contains a server and a client in the same repository (they share a bit of code). I currently make an uberjar with the server code but now I would like to make a java .jar as well with the client. I am not sure how I should approach this with boot (or any other tool actually)?

nha14:02:48

(I don’t want to include everything in the driver - also the next step is to make a thin java wrapper around it and I will probably use the boot javac task as well)

nha14:02:38

One problem is that they have common dependencies as well (like timbre for instance).

candera14:02:53

You can have multiple folders, like client, server, and common and conditionally include subsets of those on the path when compiling.

candera14:02:02

symlinks also work well within git repositories.

candera14:02:19

I’ve used submodules at times to manage things like this, too, although that’s slightly more involved.

candera14:02:28

I don’t know how you’d manage multiple independent artifacts in a single boot.build, but I’m guessing you could just modify your paths and dependencies inside a task definition. If not, it’s not unreasonable IMO to have multiple projects in a single repo. It’s not done much in the Clojure world - for some reason we have this one repo = one project = one artifact mindset - so you might run into issues where tools make assumptions about the equivalence. But in general it should work.

nha14:02:36

Yes I am trying now. Looks like (sift :include #{"^client/*" #"^common/*"}) should work.

nha14:02:50

…or not. I am ending up with an empty jar (only manifest etc)

candera14:02:23

sift seems like a sort of odd way to do what you want, although I guess it should work. Again, not that I’ve done this, but I would be trying to do something like setting the environment as part of one of my build.boot tasks. Something like this:

candera14:02:55

(deftask client [] (merge-env! :source-paths #{"client"} ...) (comp (java ...)

candera14:02:06

That’s just off the top of my head, so probably broken.

candera14:02:18

No idea if it will work, either: have never tried to alter the environment inside a task.

candera14:02:25

Got my task working. No idea why it wasn’t working before; just kept making it look more and more like the example task until it started doing what I want it to.

nha14:02:00

Hm yes that looks cleaner to do it like that actually - I’ll try

candera15:02:51

The thing that bugs me about that approach is that you have side-effects in your task. Which is going to make them hard to compose.

candera15:02:19

I was looking for something like with-env in Boot, but it doesn’t seem to exist. Easy to build out of set-env! and get-env, though.

candera15:02:47

Or maybe Boot just really isn’t meant to create two artifacts from a single boot.build and you should have two.

candera15:02:09

Obviously, I’m not an expert.

nha15:02:29

I think it is possible to use a pod with it’s own env so I am no too worried by that. Also this is not so much a dev task (I want those to compose) as much as a task called once per build you want to release so even if it doesn’t it would be fine.

nha15:02:07

The thing is that at the moment I have “src/clj” “src/cljs” “src/cljc” folders, and that seems to complicate the task

candera15:02:32

Yeah, you don’t need to do that since the file extensions disambiguate.

candera15:02:43

I find it quite handy to just keep them in the same folders.

candera15:02:00

The correct one will get loaded: clj then cljc if Clojure, cljs then cljc if ClojureScript.

nha15:02:17

yes I read that recently

nha15:02:59

..it seems I end up without .clj files at the moment in my jar, but the “resources/” folder content is there

nha15:02:24

oh - maybe because those are .cljc files (?)

candera15:02:41

There’s a confusing thing about the terminology on “source paths” vs “resource paths”. One of them winds up in the JAR, one doesn’t, and I can never keep it straight. That may be what’s happening to you.

nha15:02:58

right - :resource-paths #{} and my jar is empty again. I need to include the sources now somehow - and make them accessible from java

candera15:02:05

If you want to call your Clojure code from Java your options are AOT (shudder) and using the Clojure API.

candera15:02:18

If you go the AOT route you won’t need the sources.

candera15:02:23

But it has a lot of sharp edges.

candera15:02:47

Of course if you go the Clojure API route you’re going to wind up with an API that won’t look familiar to most Java programmers.

nha15:02:05

Yes I saw this http://michaelrkytch.github.io/programming/clojure/interop/2015/05/26/clj-interop-require.html using the Clojure API - hence why I was planning to make a thin Java wrapper around the clojure code

nha15:02:20

But I still need to be able to publish a Clojure jar first 😛

candera15:02:27

Yeah, I think that’s a good option. You might even be able to generate it with Clojure. 🙂

nha15:02:58

Ahaha yeah 😛 one step at a time

witek15:02:17

Hi. I would like to create a Java Web Application using boot. Either an all-included mywebapp.war which I can drop into Tomcat8. Or an all-included mywebapp.jar which I can start with java -jar mywebapp.jar. Can anyone point me to a tutorial? Thank you!

nha16:02:15

hm it seems I end up with .class files in the .jar if I use the aot task, nothing but meta stuff otherwise

nha16:02:30

(but then some dependencies etc. end up in there as well)

witek16:02:55

How do I include a project directory into my webbap using the war task. I have a project directory with images, css and so on which needs to get into the root of the war file...

nha16:02:56

@witek something like (set-env! :resource-paths #{ "resources/"})

witek16:02:48

:resource-paths gets these files into WEB-INF/classes but not into / of the war file. :asset-paths seams to have no effect on war files 😞