Cursive IntelliJ working on multiple Leiningen projects & require - refer :as not working

635 views
Skip to first unread message

Niels van Klaveren

unread,
Nov 1, 2013, 11:44:49 AM11/1/13
to clo...@googlegroups.com
The release notes mention that working on multiple Leiningen projects has been improved, but how to get it working ?
I wondered if there's a preferred way to work on multiple Leiningen projects, so changes in one are reflected in the other.

- Leiningen has the option to work with the checkouts directory containing a simlink (linux) / junction link (windows) to the directories in question
- CounterClockWise has the option to add the other project to the project build path

I got things working by using the checkout directory / junction link method, and in Cursive marking the checkout source directory as a Source Root.
Is this the intended way to do it, or is there another way ?

Another thing I noticed is that require :as alias and require :refer aren't picked up, and all aliased / referred function calls are marked as "cannot resolved be resolved" warnings.
Any way I can get rid of those ?

Niels van Klaveren

unread,
Nov 1, 2013, 12:24:57 PM11/1/13
to clo...@googlegroups.com
I don't think it's the way to do it, because the checkouts /src directory gets unmarked when the project is loaded anew after an IntelliJ restart.

Colin Fleming

unread,
Nov 1, 2013, 5:06:39 PM11/1/13
to clo...@googlegroups.com
Right, this is still a little messy - this is actually something I'll be working on this week. I fixed up the existing support which wouldn't allow multiple modules at all (or at least would throw exceptions when Aether couldn't resolve the dependencies), but it's still not smart about adding one module to the classpath of another, sorry. I'll try to fix this in the next build.

The require :as alias and require :refer should definitely be working, could you let me know what your ns form looks like? Maybe drop me a mail at cur...@cursiveclojure.com rather than on the list. I'd be interested to know what your multi-project lein project looks like, too. Thanks!


--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Colin Fleming

unread,
Nov 1, 2013, 6:47:28 PM11/1/13
to clo...@googlegroups.com
BTW as a workaround you can import the dependency as a module in your project (File->Import Module...), and manually add a dependency on that module to your main project (Project Structure->Modules->{your_module}->Dependencies. That will allow symbols to be resolved from one project to the other and is basically manually doing what any future support will do automatically. That link will also survive a project refresh.

Colin Fleming

unread,
Nov 5, 2013, 1:51:00 AM11/5/13
to clo...@googlegroups.com
Hi Niels,

I've just released Cursive 0.1.05 which fixes this issue. Documentation for the Leiningen support is here. Basically you should be able to just import your project wholesale and it will automatically work out all the dependencies. Checkout dependencies are also transparently supported for interop with other tools.

Let me know if it works for you, and I'd be interested to know more about your namespace resolution problems too. Feel free to drop me a mail at cur...@cursiveclojure.com if you'd rather send it off-list.

Thanks,
Colin


--

Niels van Klaveren

unread,
Nov 5, 2013, 5:53:32 AM11/5/13
to clo...@googlegroups.com
The namepace resolution issue vanished after upgrading Cursive and re-opening the project after deleting the IntelliJ artifacts in it.
Checkouts namespacing is recognized as well, and checkouts src directories are nicely marked as such.

However, when loading the file in the REPL I get a "Could not locate menthy/utils_java/jdbc__init.class or menthy/utils_java/jdbc.clj on classpath" exception for calls to the checkout project(s).

Colin Fleming

unread,
Nov 5, 2013, 4:50:47 PM11/5/13
to clo...@googlegroups.com
Hmm, there may be some problem with the classpath there - I'll take a look.

Colin Fleming

unread,
Nov 6, 2013, 1:49:59 AM11/6/13
to clo...@googlegroups.com
Right, I had a chance to take a look at this - the classpath for the REPL unfortunately doesn't include the source directories of dependent modules. I'll fix that in the next build.

There is a workaround. In Settings->Compiler->Clojure Compiler, enable "Copy Clojure source files to output path". In Settings->Compiler, if you have "Use external build" selected then change the resource pattern for Clojure from !?*.clj to ?*.clj. Then you can build your dependent module manually (for example, by right clicking on it in the project tree and selecting Make Module '<your module>'. That will copy your Clojure files to the output path and they'll be picked up by the REPL then.

Niels van Klaveren

unread,
Nov 6, 2013, 6:01:33 AM11/6/13
to clo...@googlegroups.com
Thanks for looking into this, highly appreciated.
Reply all
Reply to author
Forward
0 new messages