Intellij dropping Angular CLI module from combined Gradle project

Answered

I've only started seeing this recently, within the past two weeks or so. Here's a simplified folder structure of the repo I'm downloading:

+-Root Folder
|---+-Gradle Project Root
|------build.gradle and Java files
|---+-Angular project root
|------Angular project files
|--Misc repo files

My workflow for the past 6 months have been: 

  1. Clone the repo
  2. Right click the root folder, select "Open folder as Intellij IDEA Project"
  3. Navigate to File > Project Structure > Modules
  4. Import the Gradle project using the Gradle Project Root folder
  5. Add a new module selecting Javascript > Angular CLI and using the Angular Project Root folder

My IntelliJ Project is now set up with two separate modules from the same parent folder and I can build my Java project with Gradle and run Angular both from IntellJ. Recently, IntelliJ has started to remove my Angular module and set the Gradle folder as the root of the IDEA Project. I've tried to add the Angular folder back and IntelliJ warns me that there's already an .iml created for the module. I try to add the Gradle folder back and it says the project is already registered. I've also removed the root folder from my machine and re-cloned and this happens again. Kind of enjoyed my all-in-one setup from 6 months ago but this odd behavior is really throwing me for a loop.

Edit for environment information:
IntelliJ IDEA 2020.3 (Ultimate Edition)
Build #IU-203.5981.155, built on November 30, 2020
Windows 10 10.0

1
5 comments

More info: I've tried using the automated "IntelilJ detected a Gradle script" popup to import the Gradle project as well as the Angular project. When I closed and reopened the IDEA project, the root of the project was two directories higher and IntelliJ started to index about 20 unrelated projects.

0
2020-12-22 17:26:17,531 [  23024]   INFO - pl.ProjectRootManagerComponent - project roots have changed (trace_hash = -624174019) 
java.lang.Throwable
at com.intellij.openapi.roots.impl.ProjectRootManagerComponent.synchronizeRoots(ProjectRootManagerComponent.java:305)
at com.intellij.openapi.roots.impl.ProjectRootManagerComponent.fireRootsChangedEvent(ProjectRootManagerComponent.java:205)
at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.fireRootsChanged(ProjectRootManagerImpl.java:459)
at com.intellij.openapi.roots.impl.ProjectRootManagerImpl$1.fireRootsChanged(ProjectRootManagerImpl.java:146)
at com.intellij.openapi.roots.impl.ProjectRootManagerImpl$1.fireRootsChanged(ProjectRootManagerImpl.java:143)
at com.intellij.openapi.roots.impl.ProjectRootManagerImpl$BatchSession.rootsChanged(ProjectRootManagerImpl.java:113)
at com.intellij.openapi.roots.impl.ProjectRootManagerImpl$BatchSession.rootsChanged(ProjectRootManagerImpl.java:121)
at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.makeRootsChange(ProjectRootManagerImpl.java:431)
at org.jetbrains.kotlin.idea.core.script.ucache.ScriptClassRootsUpdater$notifyRootsChanged$$inlined$runInEdt$1$lambda$1.invoke(ScriptClassRootsUpdater.kt:232)
at org.jetbrains.kotlin.idea.core.script.ucache.ScriptClassRootsUpdater$notifyRootsChanged$$inlined$runInEdt$1$lambda$1.invoke(ScriptClassRootsUpdater.kt:49)
at org.jetbrains.kotlin.idea.util.application.ApplicationUtilsKt$sam$com_intellij_openapi_util_Computable$0.compute(ApplicationUtils.kt)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$runWriteAction$16(ApplicationImpl.java:1009)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:988)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1009)
at org.jetbrains.kotlin.idea.util.application.ApplicationUtilsKt.runWriteAction(ApplicationUtils.kt:21)
at org.jetbrains.kotlin.idea.core.script.ucache.ScriptClassRootsUpdater$notifyRootsChanged$$inlined$runInEdt$1.run(actions.kt:61)
at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:216)
at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:24)
at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:199)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:822)
at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:324)
at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:85)
at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:134)
at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:190)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:976)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:843)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:454)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:773)
at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:453)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:822)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:501)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90

I'm now in a state where I cannot import any modules without my content root changing. I invalidate caches, delete the .idea folder in the root folder, open the root folder as the project, and click on import when IntelliJ detects my Gradle script. Everything is fine until I close IntelliJ and reopen my project. The project root is changed to either 2 directories higher or down to the Gradle project folder. Also seeing this error in the logs.

0

I think I found a workaround. When I opened the root folder, an iml was generated and a component with the name "NewModuleRootManager" was created. When I added the Gradle project, another iml was generated again with a similar component name; but in a modules folder within the .idea folder. I changed this component name to "CheckStyle-IDEA-Module" and created a new module for my Angular project. I've closed and opened the project 3 times and my module settings have remained the same. It's less than ideal but my Gradle tasks and other various tasks still work and I'll take it. I have no idea how IntelliJ decomposed this badly but something is very wrong.

0

Please create a small sample project and report the issue with steps to reproduce at YouTrack: https://youtrack.jetbrains.com/newIssue?project=IDEA

0

It appears IntelliJ wants to set the root folder as the folder that contains build.gradle and settings.gradle instead of the structure I define. Downgrading to IntelliJ IDEA 2019.3.5 (Ultimate Edition) Build #IU-193.7288.26 and I have not seen this issue despite multiple restarts of IntelliJ and invalidate cache + restarts on 2019.3.

New issue created here: https://youtrack.jetbrains.com/issue/IDEA-258861

0

Please sign in to leave a comment.