This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-04-02
Channels
- # announcements (2)
- # beginners (32)
- # boot (10)
- # calva (81)
- # cider (39)
- # clojure (56)
- # clojure-europe (8)
- # clojure-italy (7)
- # clojure-new-zealand (1)
- # clojure-nl (8)
- # clojure-poland (1)
- # clojure-spec (12)
- # clojure-uk (38)
- # clojurescript (5)
- # community-development (1)
- # core-async (55)
- # cursive (3)
- # datomic (44)
- # dirac (15)
- # emacs (20)
- # events (1)
- # fulcro (57)
- # hyperfiddle (2)
- # jobs (9)
- # juxt (9)
- # kaocha (1)
- # lein-figwheel (1)
- # off-topic (93)
- # pathom (2)
- # pedestal (3)
- # planck (3)
- # reitit (15)
- # ring (10)
- # shadow-cljs (25)
- # spacemacs (7)
- # sql (19)
- # tools-deps (8)
@noisesmith, that is really good to know! But undocumented, right?
hmm... I thought I saw it documented somewhere, let me see if I can dig it up
there are examples here and there, but I don't find anything mentioning that all the -> related macros are designed to work inside -> http://clojuredocs.org/clojure.core/as-%3E#example-568eeddae4b0f37b65a3c280
oh wow this one - I never thought of using as->
with destructuring http://clojuredocs.org/clojure.core/as-%3E#example-5b5e08e9e4b00ac801ed9e3a
I guess it's implied that nesting would work, since it isn't prohibited.
That is an interesting one with as-> and :as.
i'd like to use clojure to generate some defrecord
classes (and some helper methods) that i intend to consume from Java... eg:
(ns my.core
(:gen-class :name my.core.Support :methods [^:static [getEvents [] ...]]))
(defrecord Event [^String name ^Date date_])
(def -getEvents [] ...seq of Events...)
from Java i should be able to stuff like this:
import my.core.Event;
import my.core.Support;
...
public static void main(String[] args) {
events = new ArrayList<Event>(Support.getEvents());
// ^^ i get ClassCastException here b/c the imported Event is loaded by AppClassLoader
// but the Events produced by the clojure-compiled gen-class are loaded by clojure's DynamicClassLoader
// ... what's the best way to do this kind of thing
}
don't you have to load Support before Event at the very least?
I've found calling Clojure via Java to be much easier with the clojure.lang.RT static methods (var, require, etc.) rather than trying to use gen-class namespaces as classes
note that this is not a public api and you should not rely on it. Instead, you should use the Clojure Java API - http://clojure.github.io/clojure/javadoc/
hmm i do need to statically link/compile in my case.. .. wondering if there's a way to tell Clojure to load certain classes like these instead of dynamically complie them
you can't call the clojure API from the java code?
if you properly aot-compiled you will be able to import the classes, and the classes will in turn initialize clojure if it isn't initialized yet
oh sweet @noisesmith didn't know you could nest ->>
and as->
inside a ->
... feel like i'm gonna overuse this thoroughly now
(a gotcha is that with eg. lein, it assumes that your java needs to be compiled before your clojure, and here I think you really want the opposite)
that's fixed with `:prep-tasks ["javac" "compile"]` :prep-tasks ["compile" "javac"]
(fixed)
@atdixon what type are you defining for getEvents to return in gen-class btw?
(I assume java.util.Collection by context)
@atdixon this compiles:
interesting thx for that noisesmith, let me try something incidentally i'm using clojure-maven-plugin not lein so let me what i can find out here
@noisesmith very cool. thank you for doing that repro. it led me to a fix... while lein
excludes the .clj
sources from the built target/jar files, clojure-maven-plugin
(what i'm using) does not do this by default
so the presence of my clj
source was causing clojure to prefer loading the defrecord by dynamic compilation rather than using the .class
file that the static/linker was using - so the Event
loaded by the java compiled code was not the same as the Event
getting dynamically produced by clojure/DynamicClassLoader
anyway i'm able to configure out the clj sources so that all is getting loaded by the AppClassLoader and now i'm working---thx again !
Anyone had issues with lein deps
constantly failing with something like Could not transfer artifact amazonica:amazonica:pom:0.3.123 from/to clojars (
during docker build
and remember a solution?
This particular dependency doesn't seem like the issue, it's different every time. Works fine outside of docker.
I ended up using a multi-stage build and compiling the uberjar outside of the runtime environment. Was able to get it to work then, and with a smaller final image, so yay
How to figure out how to mute logging for Java dependency? I use flyway
and it make so huge mess in REPL by printing even debug info. In the past this was working (.setLevel (Logger/getLogger "org.flywaydb") Level/WARNING)
, but not today (new ver. of flyway? I guess they changed logger or something). How to deal with such situations?
I mean what is the one right way to set level for logging? I have to do it separately for slf4j, log4j, logback etc. or is the way to do it in one consistent way? Should I use slf4j or logback?
In most of examples I see people set this levels by logback, not in slf4j even if they use it
another question: If one of my dependency use log4j, but another use logback I guess logback will capture log4j input as facade.
Looks like flyway uses slf4j bindings, so if you use logback, you should be able to set the flyway log level in your logback.xml (or whatever method you use). I haven’t tried it myself though
Finally I did (.setLevel (org.slf4j.LoggerFactory/getLogger "org.flywaydb") Level/WARN)
but still I don’t feel it 🙂
So probably dependency from jdbc (logback) bind slf4j to logback… who knows how this hell works 🙂
Ages ago I think I saw some people talking about the http://4clojure.com site. I'd like to contribute and get it working well, e.g. this https://github.com/4clojure/4clojure/issues/309 would be good to fix.
Anyone have any pointers?
On http://repl.it one can write clojure programs, if that's what you ask.
Not quite. 4clojure is a learning platform, which works well but has some shortcomings and it seems to have been abandoned. I wondering if anyone knows the authors or has tried to get it active.
aaah, I thought that you want a replacement for http://try-clojure.org
has anyone used ions in production and can vouch for it? considering using it for a small production project
Does clojure have some command-line tools which are required by some clojure projects to run?
yes, the core clojure project has cli-tools that are installable via your package manager (eg. homebrew on a mac)
some projects depend on leiningen
More specifically, I am trying to run 'lein repl' in one such project's root, and I get 'clojure.lang.ExceptionInfo: Could not find clojure executable {:tried-paths ["/usr/local/bin/clojure"]}' which seems to indicate I should have /usr/local/bin/clojure
/usr/local/bin/clojure
is installed by homebrew on my macos system. What are you using?
its part of clojure itself
I was trying Fulcro (following this documentation here: http://book.fulcrologic.com/#_about_this_book)
So it seems it's not related to leiningen actually but how that Fulcro template is set up
I am sorry, but I don’t know.
maybe ask in #fulcro ^^!
Yeah! good idea, thanks Lennart 🙂