This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-10-31
Channels
- # bangalore-clj (3)
- # beginners (15)
- # boot (128)
- # cider (4)
- # cljs-dev (12)
- # cljsjs (1)
- # clojure (105)
- # clojure-austin (5)
- # clojure-canada (6)
- # clojure-italy (5)
- # clojure-russia (14)
- # clojure-spec (70)
- # clojure-uk (21)
- # clojurebridge (3)
- # clojurescript (264)
- # cloverage (6)
- # cursive (4)
- # data-science (6)
- # datomic (10)
- # dirac (5)
- # editors (30)
- # events (3)
- # hoplon (9)
- # klipse (7)
- # leiningen (3)
- # luminus (4)
- # off-topic (9)
- # om (5)
- # om-next (1)
- # onyx (1)
- # parinfer (2)
- # perun (28)
- # re-frame (5)
- # ring (1)
- # rum (11)
- # spacemacs (2)
- # specter (10)
- # sql (3)
- # uncomplicate (4)
- # untangled (67)
- # vim (2)
- # yada (1)
Is there some clean way of adding dependencies to a project (and the uberjar + pom built from it) from a custom-written task? set-env!
or merge-env!
successfully update :dependencies
in the boot env but if you have a pipeline with uber
and pom
, those will use the dependencies as they were when constructing the pipeline - so prior to executing earlier tasks like the one that would add the dependencies.
@jannis I remember seeing something for this but I don't find it in the API docs right now. @micha will know. That said generally I think what you're trying to do might not be advisable since it affects dependency resolution and you might get different set of deps than if you'd run it without your task
@martinklepsch Yes, although that's kind of what I'm looking for. I may have found a better way though: have a function similar to bootlaces!
that I call before the task definitions. That can then add the dependencies so it doesn't have to be done in a task.
Has anyone seen this error before, when building with boot (I think it's from aot
): java.lang.ClassNotFoundException: java.util, compiling:(clojure/tools/reader/default_data_readers.clj:1:2)
?
not seen it but general consensus around here has often been that avoiding AOT is best as long as you don't absolutely need it
yes but you can make a "shim namespace" that essentially does something like this:
(require ')
((resolve '))
then you only AOT that namespace which has zero dependencies and you don't get into any of the AOT related troubles
good luck š
https://github.com/adzerk-oss/boot-uberjar-example/blob/master/src/main/Main.java @jannis
@dominicm whats the benefit over the clj approach?
@martinklepsch my understanding is that it's simpler to understand, but I might be wrong. I know the equivalent clojure code might be considered confusing.
I think it was mostly about skipping a step, given how short the java code is.
There was some talk about injecting that file into the fileset as an option for the aot
task.
Was also thinking that this might be ncie
anyways, gotta go
Thanks @martinklepsch, that put me in the right direction, I think!
and you can have uber omit build dependencies if you make those build dependencies scope "test"
by default the uber task only includes dependencies of scope compile, runtime, and provided
generally it is sufficient to use scope test for all the build dependencies, the pom and uber etc will all work correctly then automatically
@dominicm How does the boot-uberjar-example ensure my-namespace
is available in the built uberjar (since it's not require
d anywhere other than in main.Main
)? Is it the sift
task?
both source and resource are on the class path, but source are excluded from packaging like jars
I remember that now. It's why all CLJS libraries have their sources in :resource-paths
.
The trick with main.Main
and javac
is nice. However, it seems to also build .java
sources from dependencies, generating duplicate classes and, thereby, a java compiler error
.
Hm. And after all that, I get the Exception in thread "main" java.lang.ClassNotFoundException: java.util, compiling:(clojure/tools/reader/default_data_readers.clj:1:2)
error at runtime, rather than during AOT. So it wasn't aot. I wonder what it is then.
Yep. But somehow Clojure thinks it is when it sees that (:import [java.util Calendar ...])
line in tools.reader: https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader/default_data_readers.clj#L12
I add one dependency via merge-env!
and aot
fails. If I leave the dependency out it compiles fine.
Could it be a problem that this dependency is a Clojure project that was also pre-compiled with aot
?
@jannis if you're only aot a namespace that has no :requires it shouldn't try to compile any other namespaces
That's not the problem here. I'm looking at "compile project X with aot, which depends on Y, which was also precompiled with aot". X doesn't even refer to Y anywhere in the code. It's just added as a dependency and it breaks aot compilation of X... I wish this project was open source and simpler, then I could share it.
although if X doesn't refer to Y there isn't any way that i can think of where they would interfere with each other
It is to be built into a standalone uberjar, so, yeah. I tried with the shim instead of aot but I get the same ClassNotFoundException: java.util
error at runtime instead of at compile time that way. That's the only difference.
it's basically cloaking dependencies and snuggling them in under a different name and with no version info
Yeah, hm. This is supposed to become a modular system, where each module can be executed as a standalone application but can also define code that can be imported into other projects.
that uberjar contains all the maven stuff boy needs to resolve is own dependencies the first time you run it
put the module in a normal maven package and make a separate uberjar that depends on it
Yeah, that makes sense. Build one "library" jar and one "runtime" uberjar for each module basically.
hey guys.. can someone help meā¦ Iām trying to serve stuff in ring handler from node_modules
, what should I use? wrap-resource
, wrap-file
, something else?
@ag if your node_modules
is in resource-paths
you should be able to use wrap-resource
only
but keep in mind that if you have #{"node_modules"}
then boot/java will include the content within the folder only
I mean, you won't see the node_modules
folder in there and wrap-resource
should use "."
as root path
you have two options actually, you could avoid that and use wrap-file
as well
probably the latter is more easy to use as it does not clutter your mind with the resource trickery
@ag try this:
(deftask add-node-modules []
(with-pre-wrap fileset
(let [nm (io/file "node_modules")]
(when-not (and (.exists nm) (.isDirectory nm))
(dosh "npm" "install" "react"))
(-> fileset
(add-resource (io/file ".") :include #{#"^node_modules/"})
commit!))))
ok so probably because of the number of the files
ok see above ^ š
as @richiardiandrea said, you need to include "."
to include node_modules
or else its contents will be included
@anmonteiro it looks like boot hangs before that even
now a word of caution: it's probably OK if you don't have a lot of modules, but you'll probably see substantial slow down in your build pipeline if you have a lot of modules
^ this is why I think your solution with io/file
might be better
and wrap-file
for serving
can someone give me insight on deraen.boot-sass
I canāt figure out how to feed a single .sass
file into it and get a single .css ?
say you want a css/app.css
on your class path, you need to add a folder with css/app.scss
within :source-paths
@richiardiandrea thatās the thing - it just grabs ALL sass files in the folder and tries to compile them. I need to tell it to pick up a single file.
@ag ok then I did not understand the issue in the first place š ..to pick one you would probably need to use sift
with a regex and filter out the unwanted files...
pfffā¦ migrating to boot turned out to be a lot more work than I initially expectedā¦ Kinda having hard time to convince my colleagues that this is still worthy effort
in this case tough, you have a bunch of scss
files in the src-paths
... it makes sense for the task to compile all of them right? can I ask you the reason why you want to pick one only?
also, I think that if you put an underscore as first character of the file name, it will be ignored
should be documented
@richiardiandrea yeah I found ā_ā thingy
now this thing is trying to compile every sass/scss file it can lay hands onā¦ remember my problem with npm? itās trying to compile everying in node_modulesā¦ sigh
java.lang.Exception: Error: File to import not found or unreadable: ../node_modules/rs-breakpoints/index.scss
Parent style sheet: /Users/ag.ibragimov/.boot/cache/tmp/Users/ag.ibragimov/DevProjects/finops-admin/1hwn/6qp7pj/node_modules/rs-golden-ratio-grid/sandbox/../src/index.scss
on line 2 of node_modules/rs-golden-ratio-grid/sandbox/../src/index.scss
>> @import '../node_modules/rs-breakpoints/index.scss';
why the hell is it doing so?