Fork me on GitHub

im getting into a new clojure project and i would like to structure it as a monorepo. how should i go about handling it from intellij? so the directory structure would be something like:

├── .git
│   ├── HEAD
│   ├── config
│   └── refs
│       ├── heads
│       └── tags
├── backend
│   └── project.clj
├── expolre
│   ├── case-1
│   │   └── project.clj
│   └── case-2
│       └── project.clj
└── frontend
    └── project.clj


the issue i see is that i have multiple lein projects within one git root, but i can't seem to add those as project modules


if i would create an intellij project for each of those dirs with project.clj files, then the git root would be outside of the intellij project root


@onetom That should be no problem. If you use File-&gt;New project from existing sources…, then choose your monorepo dir and lein, then you should get the option to import projects recursively. That will set your project root at the git root, and the modules will be in the correct place.


That sounds promising. What do I do when I have a new module? When I tried to add one I was only ourselves with the option of adding a Clojure project, not a Leiningen one. And the dialog was also suggesting it's for creating a library package in a Java sense


I'm afk atm but I will experiment it it more once I got home.


You can add a new module either from Cursive using File-&gt;New-&gt;Module… or add it from the command line, and then right-click the project.clj in the project view and “Add lein project” (I think, don’t have Cursive open here).


Basically, it’s easy to add and remove modules as you like, and Cursive will adapt the project as required and work out cross-module deps etc.


Oh I was trying it from the project dialog cmd-;


I’m not sure if you can do it from there.


Are these options documented anywhere or I'm just too handicapped to find the docs?

cfleming11:04:42, under “Working with multi-module projects”


I think the screenshots are slightly out of date, they’re from an older version of IntelliJ.


i see. now i remember i read it years ago. it's a slightly different example because the vcs root also contains a project and you are talking about dependent projects.


i think my confusion is rooted in the fact that in reality i have boot projects not lein projects, so initially i don't have project.clj files. i tried to open the directory with the plain File/Open... menu item, just so i can edit the build.boot files and add my lein-generate boilerplate to them, to allow me generating the initial project.cljs. BUT if i do so, intellij automatically creates a module named after the root dir of the monorepo. when i try to add modules to it with the "New Module" menu item, the new module do not appear immediately. i have to close the project dialog and open it again. looks like some bug in intellij, which hasn't been fixed for years now.


and even before I would try the New Module menu I've instinctively tried to click on the Clojure option, which now I've noticed is under the divider called ---Framework---


which btw, i have no idea what does it do, since nothing seems to be changed after i've added it. (i've skipped the add libraries option though in the following dialog, so i guess it would just register/download a basic set of jars necessary to run clojure?)


Just out of curiosity, if I have such a multi module project, are the IntelliJ indexes for a specific version of a dependency generated for every module which uses that exact dependency?


In other words am I better off from memory usage perspective having one multi-module IntelliJ project open than having a separate project for every module?


I’m trying to rebind Navigate-> Declaration to CMD-. Intellij inserts an A in the field instead of the CMD sign and a . If I try to rebind to CMD-, it works as expected. Is it me, Intellij, or Cursive?


@slipset if you could show a screenshot i could try it on my side to see if it's reproducible or not


same here on intellij 2017.1.1


So, it’s not me 🙂


it's me too 🙂


but it doesn't mean it's the same for anyone else other than the 2 of us 🙂


i tried it with the cursive plugin disabled and i got the same result


what's interesting is that the dialog becomes taller after pressing cmd-. it seems like it's trying to show a message similar to the message we get when pressing cmd-,


"Already assigned to:..."


but it's probably some other message, because it's invisible


so my guess is it's a jetbrains issue.


it doesn't depend on which action am i trying to add the cmd-. keyboard shortcut to. i tried it on Editor actions / Backspace for example.


it would make sense to try it in some of the other ide's but i don't have anything else installed


I’m on OSX btw


the CMD key kinda gave that away


yeah, just wanted to make it explicit.