Fork me on GitHub
#cursive
<
2018-01-16
>
Kent00:01:16

@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.

cfleming00:01:11

@kentoj How are you referencing the Clojure code from the Java code?

cfleming00:01:55

Do you mean that when compiling within IntelliJ, that you get compilation errors that you don’t get when using Gradle?

Kent00:01:47

Weird, it is working for me now.

Kent00:01:05

I am referencing it as an import like so: import com.example.core;

Kent00:01:22

With later core.testPrintln("Hello");

cfleming00:01:51

Oh, and com.example.core is a gen-class?

Kent00:01:02

Not sure why it wasn’t working before. Must have been a stale out/ or build/ output.

Kent00:01:44

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))

cfleming00:01:08

Ok. That is strange, with the settings you have above I would have expected that to work.

cfleming00:01:36

As you say, perhaps a clean build was required - I’m not sure.

Kent00:01:39

It is working every time now. Hmm, not sure what it was o.O

Kent00:01:06

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!

Kent00:01:17

I am going to get my company to donate to you once we have some Clojure code in production.

cfleming00:01:21

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

cfleming00:01:28

No problem! I’m glad you like it.

Kent00:01:48

This was the clincher for us, to get Java and Clojure to easily call one another from the same project.

Kent00:01:03

It is just too much of a comittment to go all in on a new language at this point

Kent00:01:23

Thanks for the hint on clojure.java.Api.var

cfleming00:01:03

Yes, and sometimes it’s just not practical to rewrite everything 🙂

cfleming00:01:21

Fortunately with Clojure it’s not required - mixing and matching them is actually pretty easy.

Kent00:01:06

I am excited to start using it more.

cfleming00:01:15

Sorry, that should have read clojure.java.api.Clojure

Kent00:01:12

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.

kennytilton13:01:30

Ah, yes, “rebuild caches”. I had this before. Thx for the reminder.

domingues14:01:16

Hello, I’m getting Error running 'REPL': Unknown error. How can I debug it?

conan14:01:45

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.

joelsanchez14:01:47

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})))}

conan14:01:36

i don't really want to add a dependency on an external private repository

conan15:01:54

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

conan15:01:42

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!

conan15:01:04

Incidentally, I just tried exactly your approach and cursive still can't resolve the dependency

joelsanchez15:01:31

I never had problems with Cursive using my approach...weird!

conan18:01:35

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?

cfleming22:01:26

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.

cfleming22:01:06

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.

cfleming22:01:29

@U053032QC I’ll look at that local-repo issue today, I’m sure I added support for that.

cfleming22:01:40

@U053032QC BTW does changing the (File. ...) in your local repo example to ( ...) work?

cfleming23:01:19

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.

cfleming23:01:58

: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?

cfleming23:01:41

I’m going to update those issues, so perhaps we can discuss over there.

conan10:01:00

: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.

cfleming21:01:05

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.

cfleming21:01:29

Also, does using :repositories with io/file work?

cfleming22:01:15

@domingues Can you send me a copy of your log? Help-&gt;Show log in Finder/Explorer