Fork me on GitHub
#boot
<
2016-11-23
>
adamfrey02:11:29

ANN: I released a new boot library, boot-asset-fingerprint for adding cache-busting fingerprints to asset urls: https://github.com/AdamFrey/boot-asset-fingerprint

alandipert03:11:28

@adamfrey: bootiful!

crisptrutski03:11:42

Overdue overhaul on this little convenience task https://github.com/crisptrutski/boot-cljs-test

crisptrutski03:11:46

Particularly interested in hearing happy upgrade stories from users before I cut the release doge

kennethkalmer05:11:00

Hi folks 👋 I’m having what seems to be a familiar issue with boot and loading resources (via |clojure.java.io/resource`>) from an uberjar and I just can’t crack it

kennethkalmer05:11:39

$ tree
.
├── boot.properties
├── build.boot
├── resources
│   └── config.edn
├── src
│   └── fleeckr
│       ├── core.clj
│       ├── db.clj
│       ├── downloader.clj
│       └── flickr.clj
└── target
    └── fleeckr.jar
$ cat build.boot
(set-env!
 :source-paths #{"src"}
 :resource-paths #{"resources" "src"}
 :dependencies '[[org.clojure/clojure "1.9.0-alpha14"]
                 [com.github.scribejava/scribejava-apis "3.2.0"]
                 [org.clojure/data.xml "0.0.8"]
                 [org.clojure/core.async "0.2.395"]
                 [com.taoensso/nippy "2.12.2"]
                 [clj-http "3.4.1"]])

(deftask build []
  (comp
   (aot :namespace '#{fleeckr.core})
   (javac)
   (pom :project 'fleeckr
        :version "0.1.0")
   (uber)
   (jar :main 'fleeckr.core
        :file "fleeckr.jar")
   (sift :include #{#"fleeckr.jar"})
   (target)))
$ unzip -l target/fleeckr.jar | grep config.edn
       82  11-07-2016 10:43   config.edn

kennethkalmer05:11:24

config.edn is in the uberjar, but when loading it I get the following in the backtrace

kennethkalmer05:11:41

Caused by: java.lang.IllegalArgumentException: Not a file: jar:file:/Users/kenneth/Code/kennethkalmer/fleeckr/target/fleeckr.jar!/config.edn
	at $fn__12275.invokeStatic(io.clj:61)
	at $fn__12275.invoke(io.clj:44)
	at $fn__12249$G__12231__12254.invoke(io.clj:35)
	at $file.invokeStatic(io.clj:424)
	at $file.invoke(io.clj:418)
	at fleeckr.flickr__init.load(Unknown Source)
	at fleeckr.flickr__init.<clinit>(Unknown Source)

kennethkalmer05:11:36

I’m a bit lost, I’ve tried many different combinations of :source-paths & :resource-paths and I’ve tried playing with (sift :to-resource) and (sift :add-resource) as well

kennethkalmer05:11:19

The snippet of clojure trying to load the edn file is simply:

(def config (edn/read-string (slurp (io/file (io/resource "config.edn")))))

micha06:11:19

@kennethkalmer try doing this in the repl:

micha06:11:45

boot.user=> ( "clojure/core.clj")

micha06:11:07

the resource function returns a URL

micha06:11:17

then try this

micha06:11:40

boot.user=> (print (slurp (io/resource "clojure/core.clj")))

micha06:11:11

jar entries are not files, is the problem

kennethkalmer06:11:24

think i’m following along

kennethkalmer06:11:42

thanks for the guidance, will play around a bit more later!

micha06:11:03

(io/file (io/resource ... was the issue

micha06:11:21

beacuse resource returns a URL object

kennethkalmer06:11:08

yeah, playing with it now in the repl I’m seeing it is pointing somewhere to boot’s cache, so it might not even be loading the file I’m thinking it does

kennethkalmer06:11:29

oh no, it does

kennethkalmer06:11:48

anyhoo, thanks again! lots of learning to be had

micha06:11:52

a jar entry is not a file though

kennethkalmer06:11:40

thought magic would make it so! completely new to this jar world

kennethkalmer06:11:53

have to relocate, thanks again!

micha06:11:58

good luck!

crisptrutski06:11:33

.. it can be quite jarring? (sorry guys)

deas08:11:08

Not very experienced with boot, but I got a small externs fix for CodeMirror.

deas08:11:33

Considering to bump to 5.21. Should I expect the latter move to be easy or a little more effort?

martinklepsch08:11:10

@deas hey 🙂 are you talking about the cljsjs package?

deas08:11:15

Although, not quite sure how to test it other than using it in my app.

deas08:11:36

Sorry, yes sure. cljsjs.

martinklepsch08:11:56

@deas should be relatively straightforward — maybe try and see if you end up blocked/confused? There's also #cljsjs to ask questions but here is ok too.

deas08:11:51

Well the build succeeded, but other than moving codemirror.js to src, looks like they introduced a whole lot more in src.

martinklepsch08:11:28

@deas they = cljsjs?

deas08:11:55

The CodeMirror guys.

martinklepsch08:11:18

@deas with cljsjs packages the actual source is never part of the git tree, but instead downloaded at build time.

deas08:11:35

Looks like ES6 (imports).

martinklepsch08:11:03

If you have an externs fix I suggest you do that first and increment the -N increment

deas08:11:16

@martinklepsch I understand. I am already working on cljsjs/codemirror.

deas08:11:24

I guess I need some more time to play.

deas08:11:45

Turns out 5.21 does not ship a built codemirror.js. Is there build.boot using npm I could look at?

martinklepsch08:11:30

@deas maybe you can try downloading from NPM, they seem to include the built JS there

deas08:11:20

@martinklepsch Ok, thanks so far. Got to go to the barber now. 😉

dave13:11:01

@crisptrutski i gave boot-cljs-test 0.3.0-SNAPSHOT a quick test on a project where i was using 0.2.0-SNAPSHOT before, and ran into this error:

$ boot test-cljs
Adding: ([adzerk/boot-cljs "1.9.293"] [doo "0.1.7"]) to :dependencies
clojure.lang.ExceptionInfo: Could not find artifact adzerk:boot-cljs:jar:1.9.293 in clojars ()

crisptrutski14:11:48

@dave thanks! updated snapshot

crisptrutski14:11:17

getting my cljs and boot-cljs’s confused 🙂

dave15:11:08

sweet — i’ll try it out

dave15:11:48

@crisptrutski is there a new snapshot? i tried deleting 0.3.0-SNAPSHOT locally and pulling it back down, but i’m getting the same error

tmarble16:11:31

I have some CLI tests I'd like to run via boot... what's the best (canonical) way to 1) set an env var, 2) run an executable, 3) have boot exit with the error code of the process ? Seems like https://github.com/danielsz/boot-shell isn't quite enough

vikeri16:11:06

Is there an easy way to get the relative paths of all the directories in a fileset? I know I can get it of the files by using tmp-path.

martinklepsch16:11:29

@vikeri not sure I understand correctly but I think there's a :directories key in the FS that points to the different directories (usually four or so for the different roles files can have in the fileset)

vikeri16:11:29

@martinklepsch There is a key called :dirs but I couldn’t see what I was looking for there. What I would like to get is, if I have the following files: ”src/hej.clj” “src/hopp.clj” “assets/image.png” I would like to extract ”src” “assets”

vikeri16:11:42

I could do it with regex but it feels less clean...

dave16:11:47

@tmarble there is a great library for doing shell stuff in clojure: https://github.com/Raynes/conch in fact, if you’re running your tests from boot, you don’t even have to include the dependency, it’s included as part of boot: https://github.com/boot-clj/boot/blob/master/boot/pod/src/boot/from/me/raynes/conch.clj

dave16:11:25

there is an exit-code function that waits for the process to complete and returns the exit code

tmarble16:11:35

@dave .. yep i've just discovered boot.util/dosh which runs a command, throws an exception... now just need to set the envvar

martinklepsch16:11:44

@vikeri I see. So either regex or you get all directories inside that are inside the directories listed in :dirs

tmarble16:11:53

... throws exception on non-zero exit

dave16:11:17

oh, nice

dave16:11:44

i’m not sure about setting environment variables programmatically

dave16:11:56

there is System/setenv, not sure if that would do the trick?

tmarble16:11:03

that may not work b/c pods

martinklepsch16:11:53

@vikeri roughly this new File("/your/path/").listFiles(File::isDirectory); for each directory in :dirs — this may contain duplicate entries.

vikeri16:11:44

@martinklepsch But don’t they have the absolute path to boot?

vikeri16:11:52

The cache dir in boot

martinklepsch16:11:32

they will but that should be solvable with (.getName f) (or the equiv. for dirs if it's not the same)

dave16:11:55

oh, that’s right 🙂

martinklepsch16:11:53

@vikeri all that said, if you want src and added src as :source-paths then this won't work

martinklepsch16:11:34

@vikeri do you want the directories inside the directories you entered as :source-paths etc or the directories specified as :source-paths etc

dave16:11:37

wow, it’s unbelievable the amount of java you have to write to set an environment variable for the current process

vikeri16:11:14

@martinklepsch The directories inside, src was a stupid example name 😛

dave16:11:45

there is an :env option you can pass when starting a process

tmarble16:11:59

@dave thx!

mattly17:11:06

@adamfrey oh nice, I was just about to ask if there was some prior art on asset fingerprinting with boot

martinklepsch17:11:39

@mattly there's a bunch of stuff on the wiki as well