Fork me on GitHub
#boot
<
2016-08-25
>
pvinis12:08:00

i have “icons” in asset-paths

pvinis12:08:09

how do i refer to a file in there?

pvinis12:08:23

with lein it would be with io/resource

pvinis12:08:30

how would i do that with boot?

alandipert13:08:48

@pvinis things in asset-paths are never on the classpath, so you may want to put icons in resource-paths instead

alandipert13:08:55

then you can use io/resource

pvinis13:08:53

so i put the icons as resource

pvinis13:08:19

cool, and then just (resource “bla.png”) and done?

alandipert13:08:31

theoretically

alandipert13:08:05

i take it you're making a web app? are you using boot to serve it or creating a war?

pvinis13:08:01

well, i wanna make an osx app

pvinis13:08:09

so building an uberjar

alandipert13:08:44

i see. so in that case, asset-paths could work

alandipert13:08:01

the asset/resource distinction is during boot's run, whether or not the file is added to the classpath visibile to you when building

alandipert13:08:08

anyway https://github.com/boot-clj/boot/wiki/Filesets#roles-of-files has the details, when in doubt, resource-paths

pvinis13:08:45

yea i saw that

pvinis13:08:12

thats why i thought its an asset

pvinis13:08:18

but didnt know how to refer to it

alandipert13:08:57

yeah, it depends where the io/resource code is running, in boot or in code running in the uberjar

pvinis13:08:22

where is io/resource looking at actually?

pvinis13:08:30

i have to read up on that a bit

alandipert13:08:51

"the classpath"

alandipert13:08:02

all code on the jvm runs in the context of a classpath, which is a kind of abstract filesystem

alandipert13:08:29

the cool part is you can write code to implement what code running in a classpath can see, this is what a classloader is

alandipert13:08:06

so when you call io/resource it's asking the context classloader to get the file

alandipert13:08:30

even though it has 'class' in the name any kind of file can be in it

alandipert13:08:42

such as bla.png

alandipert13:08:16

for the purposes of an app like yours, it's nice as an abstraction between your code and the filesystem

alandipert13:08:09

dunno if you're into pods yet, but they're a convenient way to make your own classloaders basically

alandipert13:08:35

little VM-like objects you control the classpath of, and the classpaths of which don't conflict with the "parent" classpath

pvinis13:08:42

i have never heard of pods

alandipert13:08:10

they're mostly for implementing tasks

alandipert13:08:19

they let tasks use dependencies that people depending on the tasks don't want to depend on directly

alandipert13:08:49

like a coffeescript task might bring in some java coffe impl. that comes also with some weird logging framework

alandipert13:08:19

the task can run all that stuff in a pod so the person who just wants their coffeescript compiled doesn't have to learn a new logging framework or deal with adding :exclusions

kenbier21:08:16

is there a boot task to move (or copy would be even better) some dir in the fileset? i want to copy target/public -> (str “target/public-” (env :asset-tag))

kenny21:08:30

@kenbier Will sift not work?

kenbier21:08:19

@kenny that was my first thought, but i only see a :move option. i suppose that could work

kenbier21:08:51

ah neat thanks!