This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-06
Channels
- # babashka-sci-dev (56)
- # beginners (13)
- # biff (3)
- # calva (24)
- # cider (2)
- # clj-together (2)
- # clojure (38)
- # clojure-europe (6)
- # clojure-norway (2)
- # clojurescript (1)
- # cursive (5)
- # introduce-yourself (3)
- # pedestal (4)
- # polylith (5)
- # portal (11)
- # re-frame (7)
- # reitit (6)
- # shadow-cljs (12)
- # spacemacs (5)
- # sql (7)
- # tools-deps (1)
I’m trying to convert to deps.edn from a lein project. So far I have most things working except java compilation for tests. Any test that includes a java file or references one fails with filenotfound (not on classpath). How do I tell deps.edn test runner to run a compile command and then use the java+clj classpath / output for tests? deps.edn:
:paths ["src" "java"]
:deps {org.clojure/clojure {:mvn/version "1.10.3"}}
:test {:extra-paths ["test"]
:extra-deps {io.github.cognitect-labs/test-runner
{:git/tag "v0.5.0" :git/sha "b3fd0d2"}}
:main-opts ["-m" "cognitect.test-runner"]
:exec-fn cognitect.test-runner.api/test}
I have a build.clj file that can create an uberjar which files reference java source and it works fine when I run it, it’s just the tests that can’t find those java classes on the classpath (using the cognitect test-runner clj -A:test
) . If I don’t reference any java classes or clojure files that reference java, tests run fine.You'll have a build.clj thing that calls javac and writes class files to disk somewhere (prior to uber jarring) you need to call that before running your tests and add the output directory to paths when running your tests
I have a function that just compiles java to target as a separate step much like the example on http://clojure.org deps page
So to run your tests you call that first, then have some alias which adds the classfiles output directory to your paths, and use that alias for running tests
Can an alias call an alias so I can put it in a single clj command, or are you suggesting a bash script or something that runs multiple commands? I can try the latter, straightforward enough. thanks!
Dear friends, I am once again having an inner struggle about licenses. With respect to Clojure, there is this [interesting article from Juxt](https://www.juxt.pro/blog/prefer-mit), but there does not seem to be a lot more intel available. I'd be grateful if you could share more resources like that, should they exist. Personally, I've always been drawn to copyleft-ish licenses. While full GPL is always controversial, there are more sensible options. Notably, MPL 2.0 have often seemed quite reasonable to me, although my legal expertise is noob-worthy. Hence, for your professional endaveours, related to the usage of Clojure in any nature, what is your stance on MPL 2.0 or other similar copyleft-ish licenses? Is is a no-go like GPL often is for a lot of companies? If so, is it a preventive measure or are you aware of obvious compatibility issues, especially with respect to the overall Clojure ecosystem?
I tried to figure it out once and just got more confused because GPL also effects your linked / built code
I like the EPL 2.0 (similar to what clojure is distributed under) since I mostly write open source libraries, and it ensures that people who use my libraries 1. can write closed source proprietary software using them (i.e. their day job) 2. ought to contribute code back to the public if they make any modifications IANAL but that is my understanding of the license. GPL with class path exception I think is similar but seems more dicey and confusing last I read into it
IME companies I've worked at who use clojure already are also open to using libraries that fall under it, but not GPL
again IANAL but MPL 2.0 looks similar. this goes into some of the differences https://opensource.stackexchange.com/questions/10860/what-are-some-differences-between-mplv2-and-eplv2
I'd use an MPL 2.0 lib. I'd probably have to check with legal at work before using it though
for my own personal libs, the patent stuff has no bearing on me but if you're releasing source code as part of your business then you might care more
Thanks for your feedback! Too bad the post didn't get more love, I find it to be a very important topic, clearly overlooked. @U4YGF4NGM Those are 2 aspects I also care about and if I'm not mistaken, the MPL 2.0 covers them as well
I'm using Selmer to template out some plain text reports. One unfortunate thing is that the lines that contain only Selmer tags (e.g., {% for thing in things %}
end up in the rendered output as blank lines. I realize for HTML this doesn't matter, but for plain text it does indeed. Does anyone know of a workaround for this, or perhaps another similar library without this limitation?
Switched from diving in the code to looking at existing issues in Selmer.. and it looks like this addressed with this (open) issue https://github.com/yogthos/Selmer/issues/115
And the related thread https://clojurians.slack.com/archives/C06MAR553/p1620329458137300 (wow it's nice having history going back so far)
I am developing a game in clojure and the entities are stored in atom’s. Each entity holds a map as value when deref’ed. Now entities are referred to as ‘entity’ in function arguments and local variables. Some functions like ‘get-position’ are looking up values in the nested entity-hashmap. Now the question is how to name the entity when dereferenced in the function args / local variables? -> Maybe entity-hash, entity-value, entityv, entityval … Is there anyone who was experienced this issue?
Also I am not sure where to call deref on an entity. For example I have a function
(defn get-position [entity] (:value (:position @entity)))
which returns the current position value in the :position component … or should the entity be deref’ed before calling get-position and look like this?:
(defn get-position [entity-hash] (:value (:position entity-hash)))
I am favoring the second variant right now, although a lot of deref’s will be everywhere in the codebase then.I'm not sure I understand the name issue, but for your second question, you should 100% pass the already deref'd value. There should only be a few places where you need to deref your atom, not far from 1. I think seeing more of the code would be helpful
The name issue is - some functions work on the atom (checking something, swap!-ing something ,… ) and some functions work on the internal map data structure. - and I have to find two different names.
I also agree that get-position for example should just work on plain map data structure, it makes it much simpler and straightforward.
It is far better to make as many pure functions as you can - they are easier to write, easier to test, and composable. I generally try to avoid making a function that manipulates the atom at all and favor writing that inline at the place of use, using swap! to apply a pure function there, thus keeping all stateful ops as close to the state as possible
@mx2000 I would recommend privileging the immutable version, keeping those called entity
and not derefing inside your functions, but calling the ATOM something special, like !entity
(I forget where I first saw the exclamation point form). Then push calls like (get-position @!entity)
up as high as possible in your stack.
Then you can test almost everything as @alexmiller says without any atoms at all, but with maps you build in your tests.
here is an immutable blackjack game I built long ago… https://github.com/sritchie/blackjack/blob/develop/src/blackjack/core.clj
I think I actually avoided ANY state by cheating and calling prompt
inside one of the functions (https://github.com/sritchie/blackjack/blob/develop/src/blackjack/core.clj#L377-L393), then pushing everything for the full game-loop into a loop-recur. But I was proud at the time that all functions except for the one with prompt
operated on immutable maps. much easier to test: https://github.com/sritchie/blackjack/blob/develop/test/blackjack/core_test.clj
If you avoid passing atoms into functions at all, there's nothing to name :)