Fork me on GitHub
#cursive
<
2017-04-21
>
onetom10:04:22

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:

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

onetom10:04:21

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

onetom10:04:20

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

cfleming10:04:21

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

onetom10:04:32

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

onetom10:04:17

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

cfleming10:04:43

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

cfleming11:04:21

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.

onetom11:04:03

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

cfleming11:04:21

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

onetom11:04:40

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

cfleming11:04:42

https://cursive-ide.com/userguide/leiningen.html, under “Working with multi-module projects”

cfleming11:04:17

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

onetom11:04:00

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.

onetom11:04:19

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.

onetom11:04:39

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

onetom11:04:06

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

onetom11:04:25

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?

onetom11:04:33

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?

slipset12:04:39

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?

onetom12:04:46

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

onetom12:04:07

same here on intellij 2017.1.1

slipset12:04:25

So, it’s not me 🙂

onetom12:04:57

it's me too 🙂

onetom12:04:35

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

onetom12:04:00

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

onetom12:04:56

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

onetom12:04:12

"Already assigned to:..."

onetom12:04:24

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

onetom12:04:25

so my guess is it's a jetbrains issue.

onetom12:04:14

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.

onetom12:04:41

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

slipset12:04:48

I’m on OSX btw

onetom12:04:08

the CMD key kinda gave that away

slipset12:04:28

yeah, just wanted to make it explicit.