This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-21
Channels
- # aatree (88)
- # admin-announcements (14)
- # alda (26)
- # announcements (4)
- # avi (6)
- # aws (7)
- # beginners (80)
- # boot (268)
- # braid-chat (58)
- # cider (4)
- # clara (54)
- # cljs-dev (16)
- # cljsrn (27)
- # clojars (13)
- # clojure (123)
- # clojure-chicago (2)
- # clojure-czech (8)
- # clojure-france (5)
- # clojure-hamburg (2)
- # clojure-miami (6)
- # clojure-nl (5)
- # clojure-russia (285)
- # clojure-spain (2)
- # clojurebridge (3)
- # clojurescript (137)
- # code-reviews (14)
- # community-development (6)
- # core-async (8)
- # core-matrix (10)
- # cursive (2)
- # datascript (1)
- # datomic (24)
- # dirac (2)
- # emacs (5)
- # hoplon (4)
- # incanter (6)
- # jobs (7)
- # ldnclj (42)
- # ldnproclodo (2)
- # leiningen (1)
- # mount (60)
- # off-topic (15)
- # om (134)
- # onyx (65)
- # perun (4)
- # portland-or (2)
- # proton (15)
- # random (1)
- # re-frame (24)
- # reagent (7)
- # testing (4)
- # yada (9)
@seancorfield: that sounds like a pretty neat solution
Hey guys, in boot, is there some util to remove the parent dir to a bunch of files with absolute path?
Just asking for lazyness
I have /home/foo/bar.cljs
and /home/bar/baz.clj
...absolute, I would like to get foo/bar.cljs
and bar/baz.clj
do you know why? Because jgit
returns of course relative paths (to the repo), but if I want to rename a file, I need an absolute path...so I transform everything...but then for add-resource, I need to normalize again everything back to relative
ok I will have a look at it
(require '[ :as io])
(def root (.toPath (io/file "/home/foo")))
(def absolute (.toPath (io/file "/home/foo/bar.cljs")))
(-> root (.relativize absolute) .toString) ;=> "bar.cljs"
using the java things makes it easy to write code that will work on windows and unix filesystems
great I did not know relativize
good !
thanks!
(def root (.toPath (io/file "/home/foo")))
(def relative (.toPath (io/file "bar.cljs")))
(-> root (.resolve relative) .toString) ;=> "/home/foo/bar.cljs"
another nice thing about the Path
objects is that they carry info about the filesystem with them
wow that's amazing, I had not explored the dark side of NIO at all š
looks like boot grabs everything in the āsourceā directly, regardless of whether itās required by the āmainā namespaceā¦ is there a way to make it just follow the requires, and leave out other things?
is there a nio wrapper for Clojure already?
well sometimes the best comes out of frustration, so it is good you did not know about it š
another nice thing about the nio api is that it's already a functional interface more or less
really, Java? wow š
it would be great if Clojure 1.9 included some of this
if they are already immutable and functional, why not?
yep but if Clojure would bump the Java dep, you could wrap and put as part of the Clojure API š
@micha maybe itās a boot-cljs thing, or maybe itās a clojurescript core thing, but Iāve got a .cljs file that I only want included in the bundle under a certain build, and not included when I run a different build. itās causing problems b/c it has some top-level effects
looks like files in asset
dirs donāt get watched + copied over when just using the normal (watch)
task. is there a way to do that? I donāt see a config option for it
@jaredly: one solution is to put it into a separate source directory and only add this directory to source-paths when you need it
@jaredly: do you use a .cljs.edn file? IIRC a shim namespace requiring all namespaces in your project is generated and used as main namespace (`:main` compiler option)
Hi. Is there somewhere an up to date example how to correctly create an uberjar? I need to deliver a runnable JAR and until recently everything worked fine. Since I introduced the target task, I only get a JAR called "project.jar" and the target directory still contains all the exploded classes. My expectation was, that after the jar task only the jar itself would be left in the file-set and that the JAR would be named after my project and version number. Probably I am doing something wrong. š
OK, reading the source of the jar task I take it, that the JAR is only added to the file-set. That explains the crowded target dir. Still somehow, the naming is weird for me.
@ska: when exploding other jars they may contain pom.properties/xml files this leads to the problem that you no longer can safely determine the right jar name
@ska: there is a file
option to the jar task to manually set it in those cases
as for removing all files except the jar you can use sift
somewhat like this (sift :include #"jarname\.jar")
:include
removes all files from the fileset not matching the supplied regex
(If you ever want to exclude stuff use :include
+ :invert true
.)
Quick question: is it permitted in boot to add custom keys to the env?
@weavejester: permitted yes, usually not ideal though
@martinklepsch: Thanks. I think the env is the best place for this. I need a way of persisting environment data into a pod.
The only other way I can think of is to use a file
what kind of data is it?
Itās for the boot implementation of environ
ah neat, so you're trying to fix the problem that env vars are not available in pods
Exactly
Leiningen has a similar problem, but I use a hidden ā.lein-envā for that.
I was thinking with boot I could use a key like: ::environ.boot/env
Why not take the same approach with boot?
So thatās another option. I could use a file to pass the data into the pod.
I.e. the first task invocation would write a file .environ
and in newly created pods you look things up from that file if it exists
(where "write a file" = "add file to fileset/classpath")
Yeah, thatās basically what the PR does that Iām looking at right now. I was just wondering if there was a better way.
And as I looked into the source code for pods, the fact they persist env was tempting.
Or at least, itās recommended they do.
I think putting things in boot's global env would work but people usually avoid it. Can't provide any useful examples where it might cause problems though. š
Maybe Iāll stick with a file for now.
It seems the safer option.
ah one comes to mind: by putting it in env you rely on people enrichting (get-env)
vs creating a new env themselves
most of the time pods are created that way but still it's an assumption and not the rule.
@weavejester is in the house! š
Seems like files are the way to go, then.
Incidentally, Boot is looking nicer and nicer.
@weavejester: I should do more PRs to your projects your feedback is always fantastic
@martinklepsch: Well, there are some PRs that I manage to forget about, so Iām not sure about āalwaysā
@weavejester: fwiw not much has changed about boot since 2.0, most stuff is improvements and fixes
@weavejester: ok then lets say: if you manage to give feedback, it's always great š
Haha, maybe Iāll accept that
@weavejester: I'm thinking the task should write the file by default, there's not much reason not to do it + it eases usage when people add their tests etc (or other things that access env vars from within pods)
@martinklepsch: Iāll go with that option then
@martinklepsch: Thanks for taking a look over the PR yourself.
cheers
@weavejester: I use environ (but not the lein plugin) with boot, and I havenāt had any issues. Iām not using ENV vars in pods, though. Dev-time-only stuff is configured in build.boot
.
Itās a bit odd to have a file called .lein-env
in a boot project, but other than that, itās seemless.
are jvm system properties not an option? they have the merit of jvm-globalness
@jgdavey: The .lein-env file should only appear if youāre using Leiningen.
Unless youāre adding it in manually?
Ah, okay.
Environ has a boot task, but currently it doesnāt work in pods.
The .lein-env file is really just designed to transfer stuff from lein into the new environment.
It follows well the ā12-factorā style of application. I use .lein-env
for dev, and environment variable (and sometimes system properties) for prod
@martinklepsch: is the .cljs.edn stuff documented anywhere? Iām currently using the :main
option directly
that it's still under the multiple builds section is a bit misleading
boot-cljs could use a documentation makeover š
how does boot find the .cljs.edn file? Do they have to be in asset-paths, or resource-paths?
@jaredly: resource or source paths is best, might even work with asset paths
@jaredly: exactly
@martinklepsch: Sorry to be late. You answered my question earlier saying that several POMs (after exploding JARs) would confuse boot making it impossible to compute the correct filename. 1) It used to work earlier? Why was this changed? 2) Does this mean, that the steps of a task can only ever communicate via files and env and that the information of the project itself is not passed along from step to step?
@ska: usually when making a jar the pom
task and the jar
task talk to each other via the pom.xml
file. The jar tasks extracts the name and version and uses it for the filename. Boot does not really have the concept of a "project".
@ska: I think earlier the code was "if there are multiple pom.xml, use the first" now it's "if there are multiple, don't assume things"
is there a template for just spawning a process with boot?
like a helper function
@pesterhazy: you mean like (sh "ls -la")
?
oh. yes
no idea how I missed that
@martinklepsch: OK, I understand the change to that is does not work anymore. Makes sense. The fact that the project information is not available throughout the whole pipeline seems weird to me. That information is quite central in the scope of a project. Is there some deeper thinking behind this that I don't see yet or was there just no time to do it?
@ska: I think the point is just that "project" is an implementation detail of making jars and boot isn't bothering with it
Like where else do you need project information than for making the jar?
like if you use boot to build an npm module or something, the package.json file would be the canonical project descriptor
so tying boot to a specific thing like the pom structure just seemed unnecessary and problematic
so i recommend inspecting the pom.xml wherever you would use the project info, because the pom must contain the info you need
Now, you've lost me. It is tying to the POM by using that to pass information from step to step instead of providing an abstraction on it.
there are plenty of functions included in boot to extract info from the pom: https://github.com/boot-clj/boot/blob/master/doc/boot.pod.md#jars
Hmmm... "Boot is a Clojure build framework [...]. Boot provides a runtime environment that includes all of the tools needed to build Clojure projects from scripts written in Clojure that run in the context of the project." --> to me that sounds like package.json is not a use case and it implies the project context.
the pom is the fundamental abstraction here, and there is nothing you can add to it because it's constrained by the maven requirements
Maybe all my question would go away, if there was a built-in uberjar tasks. It seems too hard to do such a simple thing.
(def project-info {:project 'foo/bar :version "1.2.3"})
(let [{:keys [project version]} project-info]
(task-options!
jar {:file (format "%s-%s.jar" (name project) version)}
pom {:project project :version version}))
but one of the things i like about boot is that it totally works without a project context
Maybe I am still in Maven land and not yet ready for gradle. Oh, wait, that's leiningen and boot. š
PSA: i just pushed v1.1.0 of https://github.com/adzerk-oss/boot-jar2bin -- there is now a --jvm-opt
flag so you can set JVM options for your executables
e.g.
boot aot pom uber jar bin --jvm-opt -Dclojure.compiler.direct-linking=true
@micha: Yes, and I already considered going down that route. I wasn't sure about dynamically setting things, yet. And it somehow felt like re-implementing widespread defaults.
But I will just do it like that for the time being to be able to go on with the project itself.
@ska, maybe adding a snippet might help? https://github.com/boot-clj/boot/wiki/Snippets
i guess our thinking was that if we decided on a project structure, then you wouldn't be able to do this kind of thing
for example if you want to make an uberjar that has exclusions that can't be expressed as regex, can you do it?
with boot you can just remove things from the fileset arbitrarily between the uber
and jar
tasks
i'd be interested in hearing ideas about how to differentiate the project pom from poms pulled in by uber task
Anyway. I have a solution. Maybe I will come to the conclusion later that it is worth the extra effort. Maybe I won't. For this project I might switch back to leiningen, who knows.
Question about task order with comp
: In https://github.com/pesterhazy/boot-react-native/blob/feature/cli-ios-sim/example/build.boot I'd like to make a task run after rn/after-cljsbuild
but if I add a task (`with-pre-wrap`) at the end of the comp
, it gets run at the wrong time
put it before target. but also be aware that the middleware format allows you to run code/initialize tasks before they're actually run
(deftask run-in-simulator
"Run the app in the simulator"
[]
(let [running (atom false)]
(c/with-pre-wrap fileset
(println "**** run-in-simulator:" @running)
(when-not @running
(reset! running true)
#_(binding [util/*sh-dir* "app"]
(util/dosh "node" "node_modules/react-native/local-cli/cli.js" "run-ios")))
fileset)))
that's my code. But the println
gets executed at the wrong time
@ska perhaps the solution is for the uber task to put metadata on the files it extracts into the fileset
then the multiple poms issue would have an easy solution, the jar task could ignore those poms from dependency jars
@martinklepsch: I think the reason may be that after-cljsbuild
delays its work?
it uses with-post-wrap
@ska: did you use :refer :all
? And did you just say it loud and clear? š
@pesterhazy: There are multiple with-pre/post-wrap tasks in the react-native thing ā should it be ran after the packager is being ran?
maybe try with-post-wrap
that seems to work
but it's more of a guess, the react-native tasks are a bit hard to follow
but then I need to move run-in-simulator
to the top of the chain
yup that works
@martinklepsch: No, I did no such thing. It was there without me doing anything. At least not on purpose.
oh, didn't know haha
sorry then @ska
@martinklepsch: If you witness me doing a :refer :all anytime (other that core.async) I owe you a beer.
I'll keep that in mind š
goes to github searches really old github projects of @ska using :refer :all
Hey, whatās a good way to not include certain files, directories from your path in resources for making uberjar?
yeah, I tried it a while back.. is there an example? I want to only include say lib/resources/.+/dir
in uberjar and ignore the other directories in those directories
ā additionally, has someone done any work around deduping depdendencies or removing classes not being used from jars?
boot uber --include 'lib/resources/.+/dir' show -f
== (boot (uber :include #{#"lib/resources/.+/dir"}) (show :fileset true))
ah, thanks @alandipert
np. w/ code is a faster way to develop task stacks in the repl... you can do boot repl
and drive the build that way
if/when you update your build.boot, you can reload it in the repl with (load-file "build.boot")
how do I reset the repl setup in this case? or does it do that itself? [Iād like to think boot does the right thing and doesnāt set any globals, just checking :)]
well, developing on the build.boot itself is kind of a special case
any tasks you define in build.boot are global
but unless you define new ones, no, nothing is retained between boot
calls
hello guys, is there a magic way to get the jar files given a dependency inside boot (maybe part of aether.clj?)
@richiardiandrea: https://github.com/boot-clj/boot/blob/master/doc/boot.pod.md#resolve-dependency-jar
if you want to get all the jar files you can use this one: https://github.com/boot-clj/boot/blob/master/doc/boot.pod.md#resolve-dependency-jars
awesome, I don't even need to map š
basically I need to fetch the source jar, if present
so yep, I just need to add _source