herpnderpn
herpnderpn

Reputation: 701

How to remove Modules from a Intellij Maven Project permanently?

I am currently working on a larger scale Maven-based project in IntelliJIdea 12.1.6 Ultimate. I have been working with IntelliJIdea since about 5 months.

An included module has dependencies on another module. The dependent module's source was also part of my project until recently. Since I removed the dependent module from my project, I get compile errors whenever I am trying to compile the source without maven.

The pom.xml of removed modules in Intellij seem to be placed onto the Settings->Maven->Ignored Files. I cant seem to remove it from there, only check or uncheck it. It's not possible to include the module again since IntelliJ will say its still under Ignored Files.

2 ways allow me to compile again: Uncheck the pom from Ignored files, which will include the module again in my project. Or delete the source of the dependent module, so my project will load the dependent module from the maven repository. But whenever I update my project from svn, the source of the dependent module is restored (I don't know why this even happens since its not part my project) and the cycle begins anew.

I googled this for a while since it gets really annoying. It became a problem with several excluded modules. I could rebuild the intellij-project from scratch but since a lot of IntelliJ settings were made (not related to the problem) I would rather solve this.

Any help is appreciated, I guess I must be missing something

Upvotes: 21

Views: 45469

Answers (5)

Emmaroland
Emmaroland

Reputation: 39

If anyone is still experiencing this. This is what worked for me:

  1. Rigth click on the module to remove.
  2. Select "Remove Module" fro the context menu.
  3. Right click on the same module again. This time you should see an option "delete" in the context menu.
  4. Click on "delete" and the module is gone.

Hope this helps

Upvotes: 0

manikanta nvsr
manikanta nvsr

Reputation: 567

In case someone encounters a similar problem in recent times, the following steps worked for me:

  1. Right-click on the project/module that you want to remove.
  2. Select "Maven" from the context menu.
  3. Choose "Unlink Maven Projects" from the dropdown list.
  4. Finally, select "Remove" to delete the project/module.

Upvotes: 1

jmkgreen
jmkgreen

Reputation: 1643

This may not relate directly to the OP, but...

Using IntelliJ 2016.5, to remove a Maven module and it's underlying source code and remove it as a sub-module from the parent, go to the Project Files tab, find the unwanted module and use the triangle symbol to open it, then delete the entry that represents it on disk.

Hitting Delete on the module itself will only mark it as hidden within the IDE.

Upvotes: 2

herpnderpn
herpnderpn

Reputation: 701

A collegue who has more in-depth knowledge of maven told me the answer:

The trick is not to remove the source module from the intellij project but to remove it from maven (in the maven projects tab in intellij). Intellij will ask then to remove the source module also from the intellij project and its finally gone.

Right click on the maven project -> remove projects

Would not have guessed this makes such a difference.

Upvotes: 49

Andrey Chaschev
Andrey Chaschev

Reputation: 16476

Do any of these two points work for you:

  • NEW there might be dependency in one of your sub-modules pointing to the removed artifact. To make sure it's the situation, you may want to rename your $HOME/.m2 and rebuild the project. If this is indeed the case, just search for the dependency in your poms and delete it from sub-modules
  • right click on the parent pom.xml -> Maven -> Reimport
  • copy the project into a separate dir. File -> Import Project -> Choose newly created dir -> Choose Maven?

PS. Idea is excellent in maintaining the project structure in accordance with Maven project. Once you make a change to your pom, you need to reload the project. Idea can also automatically detect changes made to your pom.xml and apply them to project. To enable this, press Ctrl+Shift+A, type 'maven auto', choose "Importing", checkbox "Import Maven project automatically";

Upvotes: 2

Related Questions