Mark directories as excluded by external script

已回答

Hello, we have multiple Android apps under single monorepo, which is working as single IDE project, using Gradle as import/sync tool.

To optimize local development, we introduced a script that selects only a subset of needed modules (projects) at a time by providing different  set of included builds in `settings.gradle`.

However Intellij IDEA indexes whole monorepo contents after Gradle sync/import.

First of all, I want to make sure if it's worth the effort. Is that right that excluding a lot of directories in IDE will improve performance of certain scenarios? We have ~2m loc and ~1500 gradle modules in that monorepo and selection of single project can lead to exclusion of ⅔ of the codebase.

I expect that: 

- initial indexing

- re-index after each Gradle sync

- and probably even Code analysis?? will improve

Right? Anything else?

 

If that is the case, than how to tell IDE about this intention? I saw this post: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360008137000-Mark-directory-as-excluded-programmatically?page=1#community_comment_360001593799

But as far as I understand it's only available through Plugin API? I have an CLI app, so it will not help me.

I saw a mention of lightweight alternative for scripting: https://plugins.jetbrains.com/docs/intellij/plugin-alternatives.html#ide-scripting-console , but I am not sure I can execute this script from separate CLI application. is that right?

So I'am currently exploring the way of manually building `.idea/my_project.iml`, consisting of something like:

<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
  <component name="AdditionalModuleElements">
    <content url="file://$MODULE_DIR$" dumb="true">
      <excludeFolder url="file://$MODULE_DIR$/app" />
      <excludeFolder url="file://$MODULE_DIR$/framework" />
    </content>
  </component>
</module>

which I observe being created when I add exclusions via IDE dialog.

 

Any advice on what method is best for me is really appreciated. And also i'am looking into any insight about potential performance impact of these exclusions.

Thank you!

6

Hello, Dmitriy!

It should be possible, but it depends on your monorepo's structure.

You would have to detach the “root” Project and link desired sub-Project(s) instead.

With this configuration, IDEA should only process the linked Project and the Projects listed in its' included builds.

0

请先登录再写评论。