This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-01-16
Channels
- # beginners (115)
- # boot (13)
- # boot-dev (13)
- # chestnut (1)
- # cider (1)
- # clara (10)
- # cljs-dev (21)
- # cljsjs (1)
- # cljsrn (2)
- # clojure (120)
- # clojure-dusseldorf (2)
- # clojure-greece (13)
- # clojure-ireland (1)
- # clojure-italy (3)
- # clojure-nlp (3)
- # clojure-russia (2)
- # clojure-spec (13)
- # clojure-uk (82)
- # clojured (5)
- # clojurescript (47)
- # core-async (2)
- # core-logic (8)
- # cursive (45)
- # datomic (2)
- # editors (1)
- # emacs (39)
- # fulcro (166)
- # graphql (1)
- # hoplon (16)
- # keechma (5)
- # off-topic (202)
- # perun (4)
- # protorepl (7)
- # re-frame (28)
- # reagent (13)
- # ring (27)
- # ring-swagger (16)
- # rum (1)
- # shadow-cljs (25)
- # spacemacs (20)
- # sql (141)
- # yada (4)
@cfleming The problem I am having is that IntelliJ does not see the Clojure code from the Java code. I imagine this is some sort of compilation or classpath issue? Gradle build works, running the built JAR works, only development in IntelliJ has the issue.
Do you mean that when compiling within IntelliJ, that you get compilation errors that you don’t get when using Gradle?
Yes, it looks like this:
(ns com.example.core
(:gen-class
:name com.example.core
:methods [#^{:static true} [testPrintln [String] String]]))
(defn support [x]
(println (str "Hello " x))
(str "Hello " x))
(defn -support [x]
(support x))
Ok. That is strange, with the settings you have above I would have expected that to work.
The main thing I wanted was to be able to debug through Java and Clojure seamlessly, which I have now. Thank you so much for making that plugin!
I am going to get my company to donate to you once we have some Clojure code in production.
In my case, the dependencies are the other way around - my Clojure code depends on my Java code, and when I have to call into Clojure from Java I do it using clojure.java.Api.var
This was the clincher for us, to get Java and Clojure to easily call one another from the same project.
Fortunately with Clojure it’s not required - mixing and matching them is actually pretty easy.
Ok, thanks. I’ll be reading the Java interop section of Stuart Halloway’s book when it comes out in February so I’ll catch it there as well.
Ah, yes, “rebuild caches”. I had this before. Thx for the reminder.
A question about best practice: I have a project that uses Datomic and has a cljs frontend. Datomic is a private jar, so it needs to be installed locally in the project and checked into scm, so that Heroku gets it, but Cursive can't read dependencies from a local repo (https://github.com/cursive-ide/cursive/issues/333), i.e. like this:
:repositories [["local" ~(str (.toURI (java.io.File. "repo")))]]
I've seen suggestions that using an absolute path like this will work, but I haven't been able to make it work.
Using a :local-repo
solves the problem as I can keep the Datomic dependency in there, but then the project's classpath is too long to start a REPL as this adds a lot of characters beyond the standard ~/.m2
in each path, and it dies if I do this (https://github.com/cursive-ide/cursive/issues/1150).
What's the best way to set up the project so that Cursive can find the dep it needs and can start a REPL? I'd really like it to run with a default run config or lein repl
, and with the standard figwheel setup using a normal clojure.main.not sure I understand but I have this in my project.clj and I never had to worry about Datomic
:repositories {""
~(merge
{:url ""}
(let [username (System/getenv "DATOMIC__USERNAME")
password (System/getenv "DATOMIC__PASSWORD")]
(when (and username password)
{:username username
:password password})))}
if a new engineer needs the project, they shouldn't have to add env vars really. it may be unavoidable, which is why i'm interested in what the current best approach is. it seems a shame that cursive is the limiting factor here, so i was wondering whether there was a workaround
the gpg approach is possible, but i have not been able to get gpg working. it's cost me 2 days already and i've decided not to sink any more time into it!
Incidentally, I just tried exactly your approach and cursive still can't resolve the dependency
I never had problems with Cursive using my approach...weird!
I don't think cursive can execute code using ~
in a project.clj
, it may be that you already had datomic in your local maven repo?
Cursive does execute code in the project files, or at least it delegates to lein which does that. The issue is generally finding relative files - Cursive runs lein in-process, and Java processes can’t change the CWD.
Cursive does some black magic which means that most of the
functions work correctly, but things like (File. ...)
will not since there’s no way to hook that.
@U053032QC I’ll look at that local-repo issue today, I’m sure I added support for that.
@U053032QC BTW does changing the (File. ...)
in your local repo example to (
work?
Ok, I’ve just investigated this. I have not tested this, but I believe the :repositories
snippet should work if (File. ...)
is replaced as described above.
:local-repo
should also work. #1150 should be obsolete these days, if you’re still receiving an error with this could you send it to me?
:local-repo
does work, i can mvn deploy:deploy-file
the datomic jar and pom into a file within the project and commit that to scm, but then leiningen uses the local repo directory to put all its dependencies. Since the path to that directory is longer than the one in my home directory, it blows the max classpath length, and starting a REPL kills Intellij. So it's not practically usable even if it does work.
What’s the error you receive? The max classpath length thing should have been fixed, and I’m concerned that it kills IntelliJ - it shouldn’t.
@domingues Can you send me a copy of your log? Help->Show log in Finder/Explorer