IntelliJ - Multiple modules in 1 project - java

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.

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.

How can I automate a few steps in eclipse?

For example - Anytime I make any changes in any project I have to rebuild around 2-3 projects present in the workspace.
Is there any solution that, just by typing some shortcut keys it may start debugging those particular projects automatically.

Can Eclipse Neon determinate the projects I don't need for developement?

I'm working on a rather big RCP application, where only 2 / 100 projects are written and maintained by me. I do have dependencies on other projects and these projects might depend on another project as well.
Since Eclipse takes a lot of time to start up and loading (might even crashing sometimes if not ready) I was wondering if Eclipse Neon could determinate the projects I don't need so I could wipe them out of the workspace to fasten up the loading.
If it is helpful: We use gradle to build the project.
It's hard to know exactly how your projects relate to one another but I'm guessing you could use gradle's new composite build support (added in v3.1) to have some projects as source dependencies and others as binary dependencies.
You could then wipe out everything that's not part of the composite build from your eclipse workspace. You might even make use of this snippet to see what source folders are in your eclipse workspace... perhaps you could write a gradle task to do the wiping?
I'm assuming you are using buildship?

Closing unused modules in intellij idea like in eclipse

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

Configure Eclipse to launch a fixed project in a workspace?

I have a small workspace with 3 projects. One main (Swing) application, two other projects that are just libraries.
Now, whenever I change stuff in my library project and want to execute i.e. run with Ctrl+F11) or debug , I have to select my main project first and run that.
Is there any way to set this up more smoothly, so I can just run my program regardless of which of my 3 project that is selected ?
Have a look at the "Launching" preference page. At the botton you can select *Always launch the previously launched application. That should do the trick...
If you are using Maven you can create hierarchical structure of projects, i.e. head and child projects. In this case try to define Run/Debug profile on the parent's project level. Probably it will work from any other child project.
I personally have never try this and unfortunately cannot try this right now but I hope it will work for you.
If it does not work it seem you have to create your own eclipse plugin.
Good luck.

Categories