Fork me on GitHub
#tools-deps
<
2018-09-05
>
maleghast08:09:49

Hey there, everyone... I am a little lost, but probably just being stupid; I want to create an uberjar from my tools-deps based application. Any clues, links, etc..? (My Google-Fu has failed me completely)

maleghast09:09:04

@dominicm - Which Jar approach would you recommend via Pack for Docker-based deployment..?

dominicm09:09:43

@maleghast I recommend capsule as a good default 🙂

maleghast09:09:13

@dominicm - I may be doing something stupid (very likely), but on running the following:

clj -A:pack mach.pack.alpha.capsule foundation.jar -e build-dir --application-id foundation --application-version "$(git describe)" -m foundation.main
I can find the file -> mach.pack.alpha.capsule <- but not my jarfile... 😞

dominicm10:09:10

What output are you getting? None?

maleghast10:09:32

er, hold on...

dominicm11:09:56

There's a file named after the namespace, odd!

dominicm11:09:02

What's in it?

dominicm11:09:11

Also, how does your pack alias look?

dominicm11:09:04

There's a file named mach.pack.alpha.capsule in that folder

maleghast11:09:24

Yeah, I know

dominicm11:09:27

What is it?

maleghast11:09:51

I copied your command from the Pack Github page and just changed the name of the output jarfile and the app main namespace (it's up there ^^)

maleghast11:09:09

I have no idea what it is, I thought it was supposed to be there.

dominicm11:09:46

What does your pack section in deps.Edn look like?

maleghast11:09:34

:pack {:extra-deps
         {pack/pack.alpha
           {:git/url ""
            :sha "1d455f6c591f440560c57a29e6d930004d735dcf"}}
         :main-opts ["-m" "mach.pack.alpha.capsule"
                     "-m" "foundation.main"]}

mike_ananev12:09:53

@maleghast I recommend you to stay with lein for some time. pack.alpha, depstar and other have some lacks... one of them copy src files into uberjar, another doesn't copy resource folder into uberjar. I've investigated all of them and IMO lein is still preferable way to build uberjar.

dominicm13:09:46

pack does put src files in, because that's what you generally want. If you want to AOT, that is supported with pack, but you do it as an earlier step. I'm happy to point you at how you can do this, and we're working on improving the documentation to make it much clearer on how to do this kind of thing.

maleghast13:09:28

Thanks @mike1452 I will take a look... The app I am trying to UberJar is built on top of a library that @dominicm works on, that uses tools.clojure and deps.edn and as such uses neither leiningen or boot, and I am loath to add either into the mix if I don't have to. That being said, if I have to...

maleghast13:09:00

@dominicm - I think that I know what's wrong with the command I pasted above...

maleghast13:09:25

this works:

clj -A:pack foundation.jar --application-id foundation --application-version "$(git describe)" -m foundation.main

maleghast13:09:36

@dominicm - yeah, that does work... However I need to figure out how to package up the CSS etc. as the app is functioning, but looks AWFUL 😉

dominicm13:09:41

@maleghast yeah, I figured that the alias you had already had the mach.pack.alpha.capsule in the alias 🙂

maleghast13:09:58

Yeah, that's what I worked out as well...

dominicm13:09:20

@maleghast the -e build_dir option is a flag to provide an extra directory to be combined into the jar. So you can build your css/js into a directory, and have it run.

dominicm13:09:31

If you're using edge, there's an uberjar script in master which has these steps in 🙂

maleghast13:09:42

Ah... Thanks! 🙂

maleghast13:09:51

(I am using edge)

pesterhazy14:09:55

e.g. clojure -Spath | unpack-cp, then cd to that directory and run grep from there

mike_ananev18:09:23

@dominicm Did you use pack/pack.alpha? can't understand how to avoid copying source files into uberjar using this tool

dominicm18:09:45

I wrote it. Is having source files in there bad?

mike_ananev10:09:40

Well it depends. I think it should as parameter, like lein does ( :omit-source true) . When I put my uberjar in external untrusted environment I don't want that my source files be availabale for other people.

dominicm10:09:56

I haven't looked into that kind of use case particularly, but I understand now. Skipping the :paths seems like a possible flag that can be added though, it shouldn't be too difficult.

mike_ananev19:09:48

Yeah. It would be great.