Update libraries during module open/close
Hello
I'd like to modify module dependencies during module open/close operations. (I need this to replace module dependencies with appropriate libraries if module removed).
I've created component with the following listener:
public class IdeaProject implements ProjectComponent, ModuleListener {
// Replace module dependencies to libraries
//...
public void projectOpened() {
//...
project.getMessageBus().connect(project).subscribe(ProjectTopics.MODULES, this);
}
public void moduleAdded(Project project, final Module module) {
// Replace libraries dependencies to this module
}
public void moduleRemoved(Project project, final Module module) {
}
But during modyfying project libraries I get the following error:
[ 120727] ERROR - ts.impl.ProjectRootManagerImpl - Assertion failed: Merged rootsChanged not allowed inside rootsChanged, rootsChanged level == 1
java.lang.Throwable
at com.intellij.openapi.diagnostic.Logger.assertTrue(Logger.java:89)
at com.intellij.openapi.roots.impl.ProjectRootManagerImpl.mergeRootsChangesDuring(ProjectRootManagerImpl.java:419)
...
I've tried to wrap library modification code into CommandProcessor.getInstance().executeCommand and ApplicationManager.getApplication().runWriteAction but this doesn't help.
Can somebody told me how is it possible to modify libraries during module open/close operation to prevent this assertion.
Attachment(s):
IdeaProject.java.zip
idea.log.zip
Please sign in to leave a comment.
Hello Pavel,
For consistency reasons, you cannot modify the libraries directly during
opening or closing of modules. You can use invokeLater() to perform the operations
asynchronously, but that won't work when the project is being closed - your
invokeLater() will be called when everything has been disposed already.
--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"