Closing unused modules in intellij idea like in eclipse - java

As I know for now there is no any feature to do that in intellij idea. I dont know why but they dont support to do that, at least this is the result which I found with all my researching. Maybe some of us manage this problem with different ways. How do you work with multiple modules in intellij? How should I increase the performance while working with multiple projects?

Closing unused modules in intellij idea like in eclipse?
You can make that module directory as excluded from that project.
Right clicked on the directory, then goto Mark Directory As -> then click Excluded it
To Add a module back, click on Project Structure button, then goto Modules section, then you can add them back

In Intellij 2017.2, you can easly load/unload modules or groups of modules :
Right click in the "Project" view
Select "Load/Unload modules"
Select modules to load/unload and click OK button
Warning : This is an "experimental" feature
Ref : jetbrains site

The Offline Module plugin let you disable or enable modules in project without deleting.
Click Disable Module in context menu in Project View, it disables the selected modules. Disabled Modules are shown in a group and can be add back by Load Module.

Projects in Eclipse are Modules in IntelliJ. I do not recommend using them the same way - ie importing unrelated projects as modules into one IntelliJ project.
Importing for example database project and application project into one is ok, or when working on one project means working on another.
But when you import too many projects into one, you will have a problem with searching and "Go To File/Class" actions, and you will use too much heap space.
Generally, when you have a lot of opened projects, there are three problems
too much used heap -> GC pauses.
switching between them is hard
closing and reopening a lot of projects is hard
To solve this, I have made Frame Switcher plugin for easier switching between projects, and reopening closed ones.
Also, when you have 32 bit Windows and have too many projects, then you need to start new IntelliJ instance, and Frame Switcher can integrate them.
There is also Missing Functionality plugin which lets you "Close All Other Projects".

Since the old "Offline Module" doesn't work, I made a plugin to utilize the mechanics of "Mark as Excluded" to quickly show/hide multiple modules.
Link to module here: https://plugins.jetbrains.com/plugin/7803?pr=idea

Related

IntelliJ: Why are my libraries not being recognized/downloaded?

IntelliJ newcomer here. I'm having some issues getting my project dependencies working:
So I have a project called ClearDialogue. It's an IDE for making branching dialogue for video games. It relies on my other project, Clear (ClearVG and ClearWindows) for creating its window and also rendering the UI. ClearDialogue also depends on LWJGL3 and a few other dependencies. The projects use Maven to manage its dependencies.
Clear is a project on my machine that I've set up in IntelliJ and successfully ran its demos. ClearDialogue however is where my trouble started; it relies on Clear to work, which is another project (not a JAR thats uploaded for it to fetch). So what I'm saying is: I need to be able to use another IntelliJ project as a library in ClearDialogue.
According to other similar questions, I can achieve this by referencing the other project in the pom file of the project that's referencing it. So I did that and it actually did appear in the "External Libraries" dropdown:
.
There are a few problems:
1) Despite Clear appearing in the External Libraries section, it's still not being recognized by the IDE as a library and when I try to build the project, errors like this are printed to the console:
.
2) It seems that Clear is the only library being downloaded despite LWJGL3 and other libraries being designated as dependencies in the pom file. They aren't being downloaded and aren't appearing in the External Libraries tab. That said, Clear itself uses some of the same libraries (LWJGL3) so is it that it's just making sure they aren't duplicated? Either way, the code itself is drawing red lines because it can't find the LWJGL3 libraries.
Does anyone know ways to fix these issues? Thanks in advance.
I managed to fix both of these problems myself.
To solve the first problem of using another project as a dependency, I was able to use the maven attributes of the projects to do so. I referenced Clear in ClearDialogue's pom file like this:
.
Then I opened the Maven view (View -> Tool Windows -> Maven) and added the pom files from Clear's own modules to the list along with the needed modules within the project itself:
.
After this I pressed the "Reimport all Maven Projects" button (the button in the picture above that looks like a refresh button) and rebuilt the project (Build -> Rebuild Project). This successfully downloaded all of my needed libraries and successfully added the local libraries from my own projects only available on the machine as well. With that I was able to successfully run to program as well.
As for the second half of my problem, I was able to find this answer from another question here on Stack Overflow, which coincidentally was how I was able to figure out how to add local dependencies as well.

Stop IntelliJ polluting Project tool window with module names?

On the back of this question, is there a way in IntelliJ to disable displaying the full .iml module name [in bold and in square brackets] next to folder name when it is simply a fully qualified version of it? It is unnecessarily noisy on a big project...
http://i.stack.imgur.com/eE5nz.png
There is a related feature request open in IntelliJ IDEA issue tracker:
IDEA-82965 Clean module names
Feel free to vote/comment.
As a newcomer to both IntelliJ and Maven, I also found the module names to be noisy. Perhaps I'll need them later, but for now I needed to be able to focus on the file directory structure and just needed them gone. Switching from "Project" to "Project Files" did the trick. The Project Files view has an option in its Options Menu to Show Modules that I was able to disable. Maven module information is no longer visible. It might not be the perfect long term solution, as I don't fully understand the difference in the views yet, but it did reduce the as-yet-unnecessary information I was being bombarded with.
(Thanks to https://youtrack.jetbrains.com/issue/IDEA-126014 for pointing this out while working on a similar issue.)

IntelliJ - Multiple modules in 1 project

Background
So I recently have migrated over to Intellij from heavy use of Eclipse. My goal is to make IntelliJ (currently v14 as of posting) my primary Java IDE. Now, I've been learning what I can over the past couple of days about IntelliJ and it's differences when compared to Eclipse so that I can move mindsets. Things like workspace -> project, and project -> module.
Problem
I want to have multiple modules in a project and simply group them. I do not want multiple windows of IntelliJ open and have to work on multiple projects. I much prefer 1 project with many groupings of modules so that I can easily move between modules. This was working, I starting importing/creating modules and proceeded to add them to a grouping (I had to change the view thingy to another and back for it to update. This thing: http://i.imgur.com/rOlh31h.png?1). Odd, but okay, it was working. Then I was importing a module but some reason it popped up saying do I want to open a new project window, or replace the current project window, I clicked X because I wanted to cancel but it replaced my current project window. Now I've lost all the imported modules.
Question
How can I make a project view persistent? This would be either a way to save a project and then load it later perhaps. It's becoming quite annoying losing all my groupings of modules.
There's no way to overwrite the current project's window through importing modules (as far as I know). Although, when one were to accidentally import a project (thinking they were importing a module) it would surely overwrite the project window if when prompted they chose to open in current window.

Import/use code from an other Intellij project

I have two Intellij projects and in one of them I want to use some classes from the other. I'm not interested in making a library, because I want both projects to update if I change the code in the shared classes.
I have tried with modules, libraries and dependencies, but it won't work.
Thank you.
EDIT:
Followed the answer, this still doesn't. Picture show dependencies.
Perhaps this is the step you're missing.
Suppose Project_B depends on Project_A. To make one module depend on another
open the "Project Structure" dialog
click on the module that will have the the dependency
click the "Dependencies" tab
click the "+" (it's platform dependent as to exactly where it's located)
click "Module Dependency..."
when the dialog opens, click on the project to depend on
I'm not entirely sure if this is what you want but it is possible to share these files using some sort of version control.
Personally I recommend Git, it's reliable and easy enough to use.
You could use commits, push and pull to sync your files.
for more info on git: http://github.com
EDIT: I found a question on stack overflow that might be able to answer yours:
Sharing Java packages between modules in IntelliJ?
This user made a third module and put the shared data in that, and then linked the third one to the first two. Maybe if you set it up like this it will work for you.

Sources from referenced projects are not deployed to Tomcat in Eclipse

I have setup a dynamic web project in eclipse with JSF in which I trust on code from another project (framework). Therefore, I added the framework project to the build path of the website project.
So far so good, Eclipse recognises every class and the project builds without errors.
Problem is though that when I do "run on server" to test it on tomcat 6.0.24, the application fails. I get ClassNotFoundException on every class from the framework project.
Is this a bug or is some specific configuration necessary for this?
I was googling and ended up here for a similar problem. I wanted to make a note for others about the current situation on Eclipse Indigo, as the terminology has changed a bit by the looks of things.
On your project properties, do a filter/search for "deployment assembly".
It is then straightforward to add a project dependency. Job Done.
Thanks to Alexander's edited answer which led me to this.
Did you check Warnings in Problems view?
Do you see Classpath entry /your/framework.jar will not be exported or published. Runtime ClassNotFoundExceptions may result warning?
If you do.
Right-Click the warning and choose Quick Fix.
Choose "Mark the associated entry as publish/export dependency." from Select a Fix box.
Click Finish.
EDIT
Now, I think I understand where disconnect is. I think now I remember the joy of figuring this out for the first time.
In your website project ( I will speculate here , but I guess you've created it as a Dynamic Web Project ):
Open project properties
Select Java EE Module Dependencies panel
Check your framework project in JAR/Module column. Beware, that for reasons not known to me, the list is not sorted ( and is not sortable ) in any particular order, so you may need to search for your project reference there.
The results of this operation will be written to /website-project/.settings/org.eclipse.wst.common.component file. Put this file into your source control.

Categories