This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-04
Channels
- # announcements (13)
- # beginners (51)
- # boot (3)
- # calva (10)
- # cider (20)
- # clj-kondo (55)
- # cljs-dev (60)
- # clojure (99)
- # clojure-europe (6)
- # clojure-gamedev (9)
- # clojure-italy (19)
- # clojure-nl (7)
- # clojure-spec (20)
- # clojure-uk (42)
- # clojurescript (96)
- # clojurex (37)
- # clojutre (1)
- # cursive (37)
- # data-science (2)
- # datomic (15)
- # defnpodcast (9)
- # duct (7)
- # emacs (6)
- # events (9)
- # fulcro (124)
- # jackdaw (4)
- # jobs (4)
- # leiningen (9)
- # malli (7)
- # mount (3)
- # off-topic (109)
- # other-languages (8)
- # re-frame (39)
- # reagent (4)
- # reitit (6)
- # remote-jobs (2)
- # rewrite-clj (36)
- # ring (4)
- # shadow-cljs (16)
- # spacemacs (16)
- # tools-deps (91)
- # vim (8)
- # yada (2)
Another use-case for https://clojure.atlassian.net/browse/TDEPS-116 — I want to create a library that has different code for different jdk versions. I do it using 2 aliases:
{:jdk8 {:extra-paths ["src/jdk8"]}
:jdk11 {:extra-paths ["src/jdk11"]}}
It would be much easier to depend on such library when you can specify extra alias when declaring a dependency to itI think I found a bug: :paths
in aliases are not picked up when there are also :deps
present. Repro:
deps.edn:
{:paths ["src" "jdk11"]
:aliases {:jdk8 {:paths ["src" "jdk8"]
:deps {org.clojure/clojure {:mvn/version "1.10.1"}}}}}
clj -Srepro -Sforce -Spath
output:
src:jdk11:/home/vlaaad/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:/home/vlaaad/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:/home/vlaaad/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar
clj -A:jdk8 -Srepro -Sforce -Spath
output:
src:/home/vlaaad/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:/home/vlaaad/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:/home/vlaaad/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar
notice: second output does not have jdk8
folder on a classpathand sometimes
:deps
are not picked up?Given this
deps.edn
:
{:paths ["src" "jdk11"]
:aliases {:jdk8 {:paths ["src" "jdk8"]}
:deps {cljfx {:mvn/version "1.5.1"}}}}
jdk8
folder, but not dependency:src:jdk8:/home/vlaaad/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:/home/vlaaad/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:/home/vlaaad/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar
EDIT: diregard this message, it was a typoIn maven that's a classifier I think. Although jdk11 had a system for having jdk-specific files added.
I don’t think mrjars have any effect on deps? That’s really a JVM thing?
On the problem above, what version of clj are you on?
@dominicm will jep 238 work with clj files as well? is it okay to make library muti-release?..
I think jep238 might not be a fitting solution for me, because I also need different dependencies for different java versions...
Yeah, won’t do that, but should work for clj files as they are loaded as resources, just like class files
This is really where maven uses classifiers and jdk properties
I was thinking of fetching the appropriate pom.xml from the jar based on jdk version
I don’t think that’s a thing
Although I have not looked at all at the maven support for mrjars
It doesn't look like it is. It could be for local/root on a jar, but for maven a separate fetch is made for the pom, completely unaware of the jdk
Not right now
sad, I'm running out of ideas how to add jdk8 support without breaking git dependencies to cljfx 😞
maven is easy, I can build poms with different deps and source paths and publish them either as different artifacts, or with different classifiers/activations
but I already have jdk11-specific deps in root deps.edn, and it seems there is no way to exclude them when using git dependency?
you could try using a lib with nil coordinate - that will merge over, but I don't remember how tools.deps handles it (could easily not work, I just don't remember)
doesn't seem to work:
given this deps.edn
:
{:paths ["src" "jdk11"]
:deps {org.openjfx/javafx-base {:mvn/version "13"}}
:aliases {:jdk8 {:paths ["src" "jdk8"]
:override-deps {org.openjfx/javafx-base nil}}}}
running clj -A:jdk8 -Srepro -Sforce -Spath
still includes javafx-base:
src:jdk8:/home/vlaaad/.m2/repository/org/clojure/clojure/1.10.1/clojure-1.10.1.jar:/home/vlaaad/.m2/repository/org/openjfx/javafx-base/13/javafx-base-13.jar:/home/vlaaad/.m2/repository/org/clojure/spec.alpha/0.2.176/spec.alpha-0.2.176.jar:/home/vlaaad/.m2/repository/org/clojure/core.specs.alpha/0.2.44/core.specs.alpha-0.2.44.jar:/home/vlaaad/.m2/repository/org/openjfx/javafx-base/13/javafx-base-13-linux.jar
and using :deps
in alias seems to interfere with :paths
so jdk8
path is not seen, as reported earlier
yeah, I'm going to look at that in a bit once I'm past my morning calls
that's surprising to me
could you also post me your clj -Sdescribe
and whether you have anything in ~/.clojure/deps.edn?
wait, you said latest but 1.10.1.148 is not a thing, should be 1.10.1.478
ah, gotcha
clj -A:jdk8 -Srepro -Sforce -Sdescribe
{:version "1.10.1.478"
:config-files ["/usr/local/lib/clojure/deps.edn" "deps.edn" ]
:config-user ""
:config-project "deps.edn"
:install-dir "/usr/local/lib/clojure"
:config-dir "/home/vlaaad/.clojure"
:cache-dir ".cpcache"
:force true
:repro true
:resolve-aliases ""
:classpath-aliases ""
:jvm-aliases ""
:main-aliases ""
:all-aliases ":jdk8"}
oh, this is the expected behavior
the :paths and :deps in an alias are new with the newest release and REPLACE the project :paths and :deps
if you want to add, you need :extra-paths or :extra-deps
I thought your complaint above was that the project :paths was not included?
re-reading what you said above...
ah, it is a bug and I see the fix
and there is a test that should have caught this, but the test is missing the is
, so it didn't fail :)
eastwood will probably warn about such tests, if it works on your code base at all.
@vlaad logged as https://clojure.atlassian.net/browse/TDEPS-142, fixed, and released in tools.deps.alpha 0.8.584, the rest is working its way through to clj
thanks for a concise and useful report! :)
I didn't that see that with clj-kondo, but I'm not running latest version
found it. yes, that's a case I want to improve. currently it only checks the direct children of (deftest ...)
like (deftest foo (= 1 2))
, but these cases were inside a let: https://github.com/borkdude/clj-kondo/issues/462
There are also typically many is/are expressions inside of testing subexpressions inside of deftest, or let/testing/let/... etc.
Eastwood uses tools.analyzer to analyze everything, then looks for all expansions of is
forms, I believe.
It is one way to do it, but can be painful to recognize the expansions of is
, which is an odd macro.
but the point is to detect that is was forgotten. so it warns when you have a deftest without a single occurrence of is?
I'd have to go back to the code to check, but I think it warns about all expressions that are not likely to be called only for their side effects, that do not have is
or are
around them.
I'll follow up in #eastwood channel after checking the code for a little bit.
@alexmiller If you run the tests through Kaocha, then this might have caught it as well: https://github.com/lambdaisland/kaocha/blob/53d06ab7c56e48cec19bc2ab41a98e0f7b2b860c/doc/clojure_test/assertions.md#clojuretest-assertion-extensions
I guess even clojure.test could have built-in warnings like: you're defining a deftest but you never called is. Or: you called testing, but you never called is.
But it’s difficult to verify that beyond lexical scope
I'm not sure how clojure.test works internally, but is there not some kind of registry to which test an assertion belongs?
There are all kinds of hooks. Maybe it's possible to verify during one of those hooks that nothing got actually checked when running a test.
I’ve also written tests with negative assertions in code that shouldn’t run in the past. In those cases, even no assertions is correct
But those are prob rare
you could also write those kind of tests as a zero? check on a "reached" count in an atom I suppose so there would always be an assertion
@U08E8UGF7 the build here is a Maven build (as with all contrib builds) so not trivial to integrate
ironically of course, given it's tools.deps
it seems the feature we discussed for clojure.test is something kaocha also does, checking at runtime when the test ends using a hook: https://github.com/lambdaisland/kaocha/blob/c97a2cbfbb029604edd42e1340c66bd4704007cf/src/kaocha/type/var.clj#L13
I would like to see this in clojure.test, but I think the chances are fairly slim it would ever get in
this is one of the many reasons why we use kaocha, of course a static analysis check would be better as well. The negative assert feature could be fixed with dedicating another name for it like (clojure.test/never-reached!)
which macros could check for. If I got the negative assert idea correct
cool! so productive, @U04V15CAJ 🙂 Can you pretty please add a deps.edn as well for us tools.deps users.
@U08E8UGF7 it's in there now. I'm trying to make it work under CLJS as well, but registering the multimethod doesn't seem to work
Found an error in one of my own projects! https://twitter.com/borkdude/status/1191482400599158785