Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to re-add module to a project in IntelliJ?

I had a project with small code sample snippets, grouped by modules, like this:

enter image description here

Each module has individual POM file and no (apparently) global one.

Previously I had one more module, called Wikidata. At some moment IntelliJ said, that this module was "removed from Maven structure" and suggested to removed from project too. I agreed and now it is gone. It is still on disk in separate folder.

My questions are

  1. How to put module back?

  2. What was that "maven structure", from which module was removed and how to control this structure?

like image 474
Dims Avatar asked Aug 13 '15 13:08

Dims


People also ask

How do I add a module to an existing project in IntelliJ?

Import an existing moduleFrom the main menu, select File | New | Module from Existing Sources. In the dialog that opens, specify the path the . iml file of the module that you want to import, and click Open. By doing so, you are attaching another module to the project without physically moving any files.

How do I re import an IntelliJ module?

Go to File > Settings > Maven > Ignored Files and uncheck the ignored files. Then re-import the module, shouldn't be greyed out anymore. Worked for me too.

How do I add a module to a project?

Add a new module to your project by clicking File > New > New Module. Provides a container for your app's source code, resource files, and app level settings such as the module-level build file and Android Manifest file. When you create a new project, the default module name is "app".

Where is modules in IntelliJ?

From the main menu, select File | Project Structure | Project Settings | Modules. Select the module for which you want to set an SDK and click Dependencies. If the necessary SDK is already defined in IntelliJ IDEA, select it from the Module SDK list.


4 Answers

  1. Go to Settings>Build, Execution, Deployment>Build Tools>Maven>Ignored Files
  2. Uncheck the files
  3. Write your code
  4. ...
  5. Profit

With regard to the maven structure. It seems that you removed the modules from one of the pom.xml files that was using it and then IntelliJ saw this and suggested that since you're no longer building these files, then perhaps you'd like to remove them.

like image 183
Craig Avatar answered Oct 16 '22 21:10

Craig


  • Open Module Settings
  • Click on "+"
  • Click on Import Module
  • Chose Wikidata.iml from your folder structure

Maybe combine this with Craigs answer.

like image 33
Stefan Sprenger Avatar answered Oct 16 '22 20:10

Stefan Sprenger


In your .idea directory you can find a modules.xml file. Open it and just add

<module fileurl="file://$PROJECT_DIR$/path_to_your_project/your_project.iml" filepath="$PROJECT_DIR$/path_to_your_project/your_project.iml" />

to the modules-element. After this the module is marked with the blue square again.

like image 5
michaeak Avatar answered Oct 16 '22 21:10

michaeak


Add by choosing "Maven"-> "+" Add Maven projects -> "pom.xml" of module you want to add. enter image description here

enter image description here

enter image description here

like image 3
anand krish Avatar answered Oct 16 '22 20:10

anand krish