Fork me on GitHub
#boot
<
2015-07-02
>
meow19:07:55

Is there any documentation on using boot for a cljs library, rather than an app? I've got one that I'm moving out of my cljs application into a standalone library namespace and I want to be able to install it locally as well as on clojars.

meow19:07:20

I'm just wondering if the standard boot pom jar install pipeline for clj libraries is different for cljs.

micha19:07:57

pkobrien: you make jars with cljs in them the same as clojure

micha19:07:18

the standard thing you said should work

micha19:07:32

does it not doit?

meow19:07:15

I'm just getting started on it.

meow19:07:26

do I need to use adzerk-oss/boot-cljs

alandipert19:07:57

@meow: no because the cljs files go in the jar uncompiled as resources (compilation is done by the consuming application)

meow19:07:33

@alandipert: Aha! That makes sense.

meow19:07:44

Do you know of any example boot file for this situation?

meow19:07:12

Or do I just ignore the fact that my code is .cljs files?

micha19:07:38

basically just ignore it

meow20:07:57

on the boot page on github it says:

This sets up the build environment. Then we constructed a pipeline of tasks:

The pom task with options to set the project ID and version, (by default only compiled artifacts end up in the fileset),

meow20:07:26

only compiled artifact end up in what fileset? And what exactly does that mean?

micha20:07:37

that's talking about the "roles" of files in the fileset

micha20:07:53

it shouldn't say "compiled", really

micha20:07:26

there are two "roles", input and output

micha20:07:36

files in the fileset can have one or both of these roles

micha20:07:00

files with the input role are files that can be input to build type tasks, like compilers for instance

micha20:07:30

files with the output role are files that can be packaged by packaging type tasks, like jar for instance

micha20:07:47

input files are files that can be input for a transformation

micha20:07:08

output files are files that can be packaged in the final artifact (i.e. end up in the jar or the target dir)

micha20:07:44

the way you assign roles is by adding the files to the fileset via :source-paths, :resource-paths, and :asset-paths

micha20:07:00

each of these corresponds to a permutation of input and output roles

micha20:07:47

so if you add the .cljs files to :source-paths they won't end up in the jar

micha20:07:54

you want to add them to :resource-paths

micha20:07:00

then they will have the output role

meow20:07:26

@micha: gotcha, thanks.

meow21:07:55

I got problems.

meow21:07:00

First problem: I can run boot poly pom jar install from the command-line without error.

meow21:07:38

but boot build-poly gets me clojure.lang.ExceptionInfo: java.lang.NullPointerException

meow21:07:31

Second problem: it doesn't seem to be installing quite right.

meow21:07:51

I'm sure I'm making simple errors with my setup.

meow21:07:14

Bueller would find my mistakes right away ... if only he were here.

micha22:07:09

pkobrien: poly isn't really a task

micha22:07:18

tasks need to return middleware

micha22:07:42

so when you put it in the pipeline and try to compose (poly) with other things you get a NPE

micha22:07:03

because (poly) doesn't return middleware

meow22:07:42

poly should just be a defn that I call

micha22:07:46

you can put task-options! and set-env! at the top level

micha22:07:54

or yeah as a function you call for side effects

micha22:07:14

why not just have the set-env and task-options as top level expressions?

meow22:07:01

because I'm going to have other libraries in the ion namespace

meow22:07:36

I thought I'd use one boot file to control them all

johnmendonca22:07:44

couldn't his poly task end with identity

micha22:07:04

johnmendonca: totally, good idea

micha22:07:22

clojure.core/identity is like the identity middleware

micha22:07:27

so you can return that

meow22:07:22

I like that

meow22:07:47

But it's still not installing correctly

micha22:07:36

what are the symptoms? simple_smile

meow22:07:48

This seems to be the meat of it:

org.sonatype.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for ion.poly.core:ion.p
oly.core:jar:LATEST
    result: #object[org.sonatype.aether.resolution.ArtifactDescriptorResult 0x865dd6 "ion.poly.core:ion.poly.core:jar:LA
TEST -> []"]
   org.sonatype.aether.resolution.VersionResolutionException: Failed to resolve version for ion.poly.core:ion.poly.core:
jar:LATEST: Could not find metadata ion.poly.core:ion.poly.core/maven-metadata.xml in local (C:\Users\Patrick\.m2\reposi
tory)
    result: #object[org.sonatype.aether.resolution.VersionResult 0x3d687a "null @ null"]
      org.sonatype.aether.transfer.MetadataNotFoundException: Could not find metadata ion.poly.core:ion.poly.core/maven-
metadata.xml in local (C:\Users\Patrick\.m2\repository)
    metadata: #object[org.sonatype.aether.util.metadata.DefaultMetadata 0x1f116b8 "ion.poly.core:ion.poly.core/maven-met
adata.xml"]

meow22:07:19

when I look in my local .m2/repository/ion/poly it doesn't look right

micha22:07:18

this happens when you try to use it, not when you install it, right?

micha22:07:35

what does the pom look like?

meow22:07:37

there is a 0.1.0 folder, a core folder, and a maven-metadata-local.xml file

micha22:07:38

can you paste that?

meow22:07:00

yes, that was the error when I tried to use the app

micha22:07:52

looks like either the pom file or the metadata is bad

micha22:07:14

sometimes maven gets into a fuxx0red state

micha22:07:33

and you need to rm -rf the directory for your project in the .m2

micha22:07:45

and reinstall

micha22:07:12

the pom looks fine to me

micha22:07:54

i'd try rm -rf ~/.m2/repository/ion/poly or something like that

meow22:07:04

I've been doing that. Same problem.

meow22:07:47

Shouldn't the maven-metadata-local.xml file be inside the 0.1.0 folder?

meow22:07:27

nevermind

micha22:07:22

what does that guy look like?

micha22:07:42

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>cljsjs</groupId>
  <artifactId>jquery</artifactId>
  <versioning>
    <release>1.8.2-1</release>
    <versions>
      <version>1.8.2-0</version>
      <version>9.9.9</version>
      <version>1.8.2-1</version>
    </versions>
    <lastUpdated>20150120004003</lastUpdated>
  </versioning>
</metadata>

micha22:07:53

that's kind of what it should look like

meow22:07:23

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
  <groupId>ion</groupId>
  <artifactId>poly</artifactId>
  <versioning>
    <release>0.1.0</release>
    <versions>
      <version>0.1.0</version>
    </versions>
    <lastUpdated>20150702223409</lastUpdated>
  </versioning>
</metadata>

micha22:07:36

looks legit to me

micha22:07:58

ok so what does the build.boot in the consumer look like?

micha22:07:07

that's the only place the problem could be i think

micha22:07:15

pkobrien: ^^

meow22:07:19

I had an error on the consuming side, getting closer

meow22:07:03

Now I get

clojure.lang.ExceptionInfo: No such namespace: ion.poly.core, could not locate ion/poly/core.cljs, ion/poly/core.cljc, o
r Closure namespace "ion.poly.core" at line 1 /C:/Users/Patrick/.boot/cache/tmp/Users/Patrick/code/ing/informing/4eg/7o2
s6s/app/core.cljs

micha22:07:40

does the jar actually contain the namespace?

meow22:07:45

so in my build.boot there I set a dependency on [ion/poly "0.1.0"]

micha22:07:47

do you have src/ion/poly/ion/poly/core.cljs in your project?

meow22:07:39

src/ion/poly/core.cljs

micha22:07:04

so you want :resource-paths #{"src"} i think

micha22:07:29

"src" will be the root of the tree that will be added to the fileset

meow22:07:39

the jar .m2\repository\ion\poly\0.1.0\poly-0.1.0.jar\ contains core.cljs and META-INF

micha22:07:07

but it should contain ion/poly/core.cljs and the META-INF stuff

meow22:07:42

okay, but what if later I add src/ion/phil/core.cljs

meow22:07:02

and I want poly and phil to be separate

micha22:07:11

if you do :resource-paths #{"src"} then the src directory will be the root of the classpath, basically

micha22:07:20

well in that case you make a different root

micha22:07:36

like maybe "src1" and "src2"

meow22:07:48

well, I was trying to avoid that

micha22:07:00

well you can use fancier things i guess

micha22:07:32

but the real question i guess is: are the projects going to be separate artifacts in maven?

micha22:07:40

if so it usually makes sense to have separate git repos

micha22:07:55

because then you can relate releases to git commits in a straightforward way

micha22:07:58

and things like that

meow22:07:11

I'm trying to reduce the overhead of multiple git repos

micha22:07:23

so maybe roll them into one maven artifact

micha22:07:33

why not have both things in the same jar?

micha22:07:50

you can have jars with both clj and cljs stuff in them

meow23:07:44

my idea was to have one git repo for several libraries

micha23:07:57

ok so one workaround that isn't too crazy i guess would be to use the sift task

meow23:07:06

keeping the repo structure simple and nonredundant

micha23:07:27

i've tried this and it never ended up being simpler simple_smile

meow23:07:36

I knew I was swimming against the current but figured I'd try it and see what it was like.

micha23:07:45

especailly if you take pull requests

micha23:07:57

or if you need to make changelogs and stuff

micha23:07:36

so you should try the sift task

micha23:07:52

have all the things in "src", and sift out the ones you don't wnat to include in the jar

micha23:07:11

boot sift --help

micha23:07:16

it does a lot of things there

micha23:07:20

too many probably

micha23:07:10

but i can imagine like (sift :include #{ #"\.cljs$" }) being part of your pipeline

micha23:07:11

or something

meow23:07:22

is there a way to prepend ion/poly/ to what goes in the jar instead?

micha23:07:34

the sift task, again!

meow23:07:55

so I can leave my specific stuff for selecting and then just prepend the namespace

micha23:07:15

(sift :move { #"\.cljs$" "ion/poly/$1" }) for instance

meow23:07:22

gtg, will look at whatever you suggest

meow23:07:43

it isn't too late for me to make separate repos for all of this if my way is just too crazy

micha23:07:53

look at the sift task, it is the swiss army knife of fileset manipulations

meow23:07:55

bbl, thanks for all your help! simple_smile

micha23:07:06

np! good luck simple_smile