Cursive Plugin and Intellij Idea 2017.1.3 Build #IU-171.4249.39

127 views
Skip to first unread message

Joachim Martillo

unread,
Jun 28, 2017, 7:32:41 AM6/28/17
to Cursive
I'm new to Clojure, but I think it would work great to provide NLP functionality in medical, financial, and legal web services.

Thus I am very interested in building mixed language Java-Scala-Clojure microservices.

I am developing problem sets and notes for an introductory course in Web Development.

Here is my article that addresses a simple mixed language Java-Clojure client application.


The article discloses that the Cursive plugin 1.5-1-2017.1 only worked partially with Intellij Idea 2017.1.3 Build #IU-171.4249.39.

Am I doing something wrong? Or is there another version of the Cursive plugin that will work with the latest subscription version of Intellij?

Almost no functionality of the Clojure-Kit (Version: 0.7.0) worked with this version of Intellij.

Daniel Compton

unread,
Jun 28, 2017, 7:25:29 PM6/28/17
to Cursive
Hi Joachim

I'm able to use Cursive 1.6.0-eap2-2017.1 with full functionality with IntelliJ 2017.1.4. I didn't notice any issues with any of the 1.5 series of Cursive and 2017.1.3 either. Did you follow these instructions to setup the Maven project? https://cursive-ide.com/userguide/projects.html

Also, did you have Clojure-Kit and Cursive both enabled at the same time? I think that is likely to not work very well.

--
You received this message because you are subscribed to the Google Groups "Cursive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cursive+u...@googlegroups.com.
To post to this group, send email to cur...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/1badce39-0b62-499d-aeef-304792ade6c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joachim Martillo

unread,
Jun 28, 2017, 8:53:22 PM6/28/17
to cur...@googlegroups.com
I'm not sure that my maven project corresponds to the type of the project described in the instructions the following page.

 https://cursive-ide.com/userguide/projects.html

I am trying to set up a mixed-language project (Java/Scala/Clojure) although in this example Scala is not used.


A Java class contains main, and a method in this class invokes the Clojure name space entry point.

Here is the Java class.

https://github.com/MartilloInventor/coursesclient3/blob/master/src/main/java/edu/webdev/CoursesClientRequest.java

Here is the Clojure name space.

https://github.com/MartilloInventor/coursesclient3/blob/master/src/main/clojure/src/edu/webdev/CoursesClientRequest.clj

I expunged Clojure-Kit and updated Cursive to Cursive 1.6.0-eap2-2017.1.

Breakpoints only work in the Java but not in the Clojure code.

Is it possible that the problem results from using the same base name for Java and for Clojure, to wit, CoursesClientRequest?

Later I will try a version of the project that uses DoCoursesClientRequest.clj instead of CoursesClientRequest.clj.






On Wed, Jun 28, 2017 at 7:25 PM, Daniel Compton <daniel.com...@gmail.com> wrote:
Hi Joachim

I'm able to use Cursive 1.6.0-eap2-2017.1 with full functionality with IntelliJ 2017.1.4. I didn't notice any issues with any of the 1.5 series of Cursive and 2017.1.3 either. Did you follow these instructions to setup the Maven project? https://cursive-ide.com/userguide/projects.html

Also, did you have Clojure-Kit and Cursive both enabled at the same time? I think that is likely to not work very well.

On Wed, Jun 28, 2017 at 11:32 PM Joachim Martillo <joachim.c...@gmail.com> wrote:
I'm new to Clojure, but I think it would work great to provide NLP functionality in medical, financial, and legal web services.

Thus I am very interested in building mixed language Java-Scala-Clojure microservices.

I am developing problem sets and notes for an introductory course in Web Development.

Here is my article that addresses a simple mixed language Java-Clojure client application.


The article discloses that the Cursive plugin 1.5-1-2017.1 only worked partially with Intellij Idea 2017.1.3 Build #IU-171.4249.39.

Am I doing something wrong? Or is there another version of the Cursive plugin that will work with the latest subscription version of Intellij?

Almost no functionality of the Clojure-Kit (Version: 0.7.0) worked with this version of Intellij.

--
You received this message because you are subscribed to the Google Groups "Cursive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cursive+unsubscribe@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/1badce39-0b62-499d-aeef-304792ade6c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Cursive" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cursive/grj9X6QeBEY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cursive+unsubscribe@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.

Frederic Merizen

unread,
Jun 29, 2017, 7:49:36 AM6/29/17
to cur...@googlegroups.com
Hi Joachim,

What strikes me as very odd is the ‘src’ component at the begging of your Clojure namespace: src.edu.webdev.CoursesClientRequest .

If you want Cursive to successfully set a break point in that namespace, you will need the parent of the src directory to be set as a source root (in my colour scheme, it would be displayed as a blue folder icon in the project view). To repeat: the parent of src, not src itself, would need to be marked as a source root. That directory would probably be the root directory of your project.

As a quick and dirty fix to check if I’m right, I would suggest that you right-click that directory (the parent of src) in the project view and click ‘Mark Directory as / Sources Root’. I predict that hat will fix Clojure breakpoints for you.

As a more viable fix, you would need to find a way to get rid of the ’src’ component at the beginning of your namespace declaration, like so

(ns edu.webdev.CoursesClientRequest

You could then either fix your build system and classpath to make this line work from java (note : no src anymore)

require.invoke( Clojure.read( "edu.webdev.CoursesClientRequest" ) );
or you could go the AOT compilation route and call your Clojure code like any old Java class. I see you’ve already got a :gen-class option that isn’t being used right now, so you’re partway there.

I’m not going to be able to help you more with either option, because I’ve never used Maven to build a Clojure project.

For the record, I would make an argument for building Clojure projects with Boot or Leiningen, Scala projects with SBT and Java projects with Gradle, Maven or Ant. I’d go out of my way to avoid having a project that makes heavy use of 2 or 3 languages, I’d prefer rather have 2 or 3 projects, each with a single master language (I’m okay with a little bit of Java in a Clojure or Scala program to ease interop), with one project depending on another, and a fairly narrow, controlled interop surface.

To be honest, Java+Scala+Clojure is not really my preferred choice. I would be afraid that it adds more complexity than it’s worth. I’m not going to say that the combination doesn’t make sense, ever, but in general, I would rather have fewer languages.

Joachim Martillo

unread,
Jul 2, 2017, 2:55:31 PM7/2/17
to cur...@googlegroups.com
The src component in front of webdev.edu is not the issue. When I first set up the project, I was using the Clojure-Kit plugin and not the Cursive module. When I tried to create the Clojure webdev.edu module under Clojure, the Clojure-Kit prepended src to webdev.edu. Before I realized that Clojure-Kit was broken and switched to the Cursive plugin, Clojure-Kit managed to mess up some of the project structure by making clojure a content root. I went into project structure, removed Clojure as a content root, and made it a source folder. Now breakpoints work fine in the Clojure file.

Thanks for all the help, guys!


Daniel Compton

unread,
Jul 2, 2017, 7:00:56 PM7/2/17
to cur...@googlegroups.com
Great news! 

I would consider completely blowing away all of the IntelliJ config and starting fresh, as there may be other settings left behind by Clojure-Kit that will interfere with Cursive and IntelliJ. Possibly not, but IMO it's not worth the risk of having to chase down a confusing bug, only to realise you just have conflicting settings.

To unsubscribe from this group and stop receiving emails from it, send an email to cursive+u...@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/1badce39-0b62-499d-aeef-304792ade6c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Cursive" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cursive/grj9X6QeBEY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cursive+u...@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Cursive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cursive+u...@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Cursive" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cursive/grj9X6QeBEY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cursive+u...@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Cursive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cursive+u...@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.

Colin Fleming

unread,
Jul 2, 2017, 9:22:58 PM7/2/17
to cur...@googlegroups.com

Hi Joachim,

My apologies for not writing earlier.

I agree with Daniel’s last comment - I would recommend replacing your previous project config entirely. I forked and cloned your repo, and did the following:

  1. File->New->Project from existing sources…, select pom.xml
  2. In the new Maven project wizard, accept Maven defaults, accept default project to import, select Java 1.8 JDK, accept default name.
  3. Agree to overwrite your existing project. This will give you a new project in a clean state.
  4. In your pom under <build>, I removed the following:
    <sourceDirectory>src/main/scala</sourceDirectory> <testSourceDirectory>src/test/scala</testSourceDirectory> . These interfered with the project import - once they were removed, src/main/java was correctly marked as a source root (blue folder in the project view).
  5. I also had to manually mark src/main/clojure as a source root, for some reason I couldn’t get IntelliJ to do that automatically based on the pom. I’ve asked the author of the Maven project (who’s an IntelliJ user) about that. If your Clojure code is not under a source root much weirdness will ensue.

Once that was done, the project imported ok.

A few comments about the interop you’re using in your project:

  1. The src/main/clojure/src directory is definitely unnecessary, that’s why Clojure-Kit prepended src to your namespace name. I moved the src/main/clojure/src/edu directory directly under src/main/clojure, and removed src from the start of your package names.
  2. When using gen-class in the ns form directly, you shouldn’t use :name - the name of the class will be the namespace name. You use :name when using bare gen-class in the namespace rather than having it inlined in the ns form. You’ll also need to import the class to be able to use it without fully qualifying it, so you’ll end up with an ns form like:
    (ns edu.webdev.CoursesClientRequest (:gen-class :methods [#^{:static true} [doCoursesClientRequest [String] Void]]) (:import (edu.webdev CoursesClientRequest)))
  3. Making the above change means that you’re defining the edu.webdev.CoursesClientRequest in two places, in Clojure and in Java - that’s why the IDE is complaining in the Java class. You’ll need to rename one of them.
  4. Once you’ve gone to all the hassle of using gen-class, the whole point is that you end up with a plain Java class at the end of it. So in your Java code, you don’t have to use Clojure.var, you can just do new CoursesClientRequest().doCoursesClientRequest() as you would with any other class.
  5. That said, gen-class is pretty fiddly and awkward. I would recommend using Clojure.var, but then you don’t need gen-class at all and you can just write idiomatic Clojure, look up the var of your entry point function and call it directly. This also means that you won’t need to AOT compile your code, which you should probably avoid anyway.
  6. When writing user code, you don’t normally use the new or dot forms directly. For method calls, instead of (. log (debug "arguments: {} {}" s (. me (toString)))) it’s idiomatic to use (.debug log "arguments: {} {}" s (.toString me)), and instead of (new com.sun.jersey.api.client.config.DefaultClientConfig) it’s idiomatic to import the Java class and then write (DefaultClientConfig.).

In general, I agree with Frederic’s comment that minimising the number of languages in a project is desirable. Interop between them all is possible but awkward, and unless you have a good reason to (you want to use Scala with Akka and Clojure with Datomic, or something like that), I’d recommend trying to use one of them idiomatically until you hit a hard limit of some kind.

Cheers,
Colin

Joachim Martillo

unread,
Jul 2, 2017, 11:10:35 PM7/2/17
to cur...@googlegroups.com
Are there any examples of microservices written completely in Clojure? I have not found anything like Dropwizard or Spring Boot for a pure Clojure environment.

Most of my microservices are written completely in Java, but because certain libraries I use are written in Scala, I have ended up writing some mixed Java Scala microservices.

Now that I am looking at event-driven investing and trading, I am incorporating a lot of Lisp code into at least one of the microservices. It is easier to port the code to Clojure than to Scala.

Hence my need to program at least one mixed Java Scala Clojure. It reminds somewhat of the early 90s when I had to do such programming in the VAX/VMS world. The DEC Engineers did a very good job of making sure that all the standard languages interoperated easily.


To unsubscribe from this group and stop receiving emails from it, send an email to cursive+unsubscribe@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cursive/1badce39-0b62-499d-aeef-304792ade6c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "Cursive" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cursive/grj9X6QeBEY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cursive+unsubscribe@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Cursive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cursive+unsubscribe@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Cursive" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cursive/grj9X6QeBEY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cursive+unsubscribe@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Cursive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cursive+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Cursive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cursive+unsubscribe@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Cursive" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cursive/grj9X6QeBEY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cursive+unsubscribe@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.

Colin Fleming

unread,
Jul 2, 2017, 11:23:20 PM7/2/17
to cur...@googlegroups.com

I think what you want for Clojure is compojure-api. This is getting pretty far outside my realm of expertise though, and I suspect you’d get better/more complete answers on the main Clojure mailing list.

You definitely can interoperate between all the JVM languages, but it’s often not the best experience due to the different ways that they munge class names etc - the code can end up fairly ugly. That said, Cursive itself is a mix of Java/Kotlin and Clojure, so it’s definitely possible. I believe Scala interop with Clojure is messier but I know of several Cursive users doing it, so it is possible. I’ve fixed various related bugs but I’ve never done anything serious with it myself.

To unsubscribe from this group and stop receiving emails from it, send an email to cursive+u...@googlegroups.com.

To post to this group, send email to cur...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages