Modifying Project Libraries in facet configuration. Follow
Hello,
I am basically trying to explore my options to best create a plugin for a custom language.
Bottomline, What I want to to is this:
-Attach jar library to module preferably, if not to project. (I have used JarRepositoryManager to get a Library object, so halfway done)
-Use the jar in a runconfiguration, the main class is in the jar.
The runconfiguration is a "generate sources" kind of thing, but not for java code. It generates xml files.
I don't really understand the way things are supposed to work so I will start with a few dumb questions to make sure I understand the basics.
-I do I need a facet to store the jar version? do I need a framework? Caveat, I want to be able to edit the version after creating the module.
-Should I modify the Library table when apply() ing a facet configuration? I see I don't need to get a write action there. When I do, I get weird errors about dispose() ing a library which has been disposed or something similar. I did not attach stacktrace because I really dont know if the cause is me editing the table where I am not supposed to.
-Should I implement this as an externalProjectDataService? I.E. configure external settings somehow, and then import library as needed?
-I was not able to attach the new library directly to the module, the createLibrary() method got me a Library without a libraryTable member, and generated exceptions and assertions when trying to attach it. Therefore, I attached a libraryorderentry ot the module and the library to the project. I did all that in facet editor apply(). IDEA didn't like that.
Thank you in advance,
Manos
Please sign in to leave a comment.
Adendum: Is a ModuleConfigurationEditorProvider what I am looking for?
Ok, I guess nobody has any feedback on any of these. Maybe someone can tell me how to interpret this exception I get when modifying the project library table:
com.intellij.util.IncorrectOperationException: Sorry but parent: Library: name:sdk:1.0.0; roots:[VFPContainer: [], VFPContainer: [], VFPContainer: [], VFPContainer: [], VFPContainer: []] has already been disposed (see the cause for stacktrace) so the child: com.intellij.openapi.util.Disposer$2@561f6223 will never be disposed
at com.intellij.openapi.util.objectTree.ObjectTree.register(ObjectTree.java:75)
at com.intellij.openapi.util.Disposer.register(Disposer.java:97)
at com.intellij.openapi.util.Disposer.register(Disposer.java:93)
at com.intellij.openapi.roots.impl.libraries.LibraryImpl.disposeMyPointers(LibraryImpl.java:669)
at com.intellij.openapi.roots.impl.libraries.LibraryImpl.commit(LibraryImpl.java:640)
at com.intellij.openapi.roots.impl.libraries.LibraryImpl.commit(LibraryImpl.java:622)
at com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor.commit(ExistingLibraryEditor.java:205)
at com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesModifiableModel.deferredCommit(LibrariesModifiableModel.java:129)
at com.intellij.openapi.roots.ui.configuration.projectRoot.BaseLibrariesConfigurable.lambda$apply$1(BaseLibrariesConfigurable.java:143)
at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1057)
at com.intellij.openapi.roots.ui.configuration.projectRoot.BaseLibrariesConfigurable.apply(BaseLibrariesConfigurable.java:141)
at com.intellij.openapi.roots.ui.configuration.ProjectStructureConfigurable.apply(ProjectStructureConfigurable.java:317)
at com.intellij.openapi.options.newEditor.ConfigurableEditor.apply(ConfigurableEditor.java:316)
at com.intellij.openapi.options.newEditor.ConfigurableEditor.apply(ConfigurableEditor.java:136)
at com.intellij.openapi.options.newEditor.ConfigurableEditor$2.actionPerformed(ConfigurableEditor.java:65)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6548)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3325)
at java.awt.Component.processEvent(Component.java:6313)
at java.awt.Container.processEvent(Container.java:2237)
at java.awt.Component.dispatchEventImpl(Component.java:4903)
at java.awt.Container.dispatchEventImpl(Container.java:2295)
at java.awt.Component.dispatchEvent(Component.java:4725)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
at java.awt.Container.dispatchEventImpl(Container.java:2281)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4725)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:737)
at java.awt.EventQueue$4.run(EventQueue.java:735)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:719)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:664)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:363)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109)
at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190)
at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235)
at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)
at java.awt.Dialog.show(Dialog.java:1077)
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:698)
at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:430)
at com.intellij.openapi.ui.DialogWrapper.invokeShow(DialogWrapper.java:1681)
at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1630)
at com.intellij.openapi.options.newEditor.SettingsDialog.lambda$show$0(SettingsDialog.java:70)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:153)
at com.intellij.openapi.options.newEditor.SettingsDialog.show(SettingsDialog.java:70)
at com.intellij.openapi.ui.DialogWrapper.showAndGet(DialogWrapper.java:1645)
at com.intellij.ide.actions.ShowSettingsUtilImpl.editConfigurable(ShowSettingsUtilImpl.java:236)
at com.intellij.ide.actions.ShowSettingsUtilImpl.editConfigurable(ShowSettingsUtilImpl.java:202)
at com.intellij.openapi.roots.ui.configuration.ModulesConfigurator.showDialog(ModulesConfigurator.java:532)
at com.intellij.openapi.roots.ui.configuration.IdeaProjectSettingsService.openModuleSettings(IdeaProjectSettingsService.java:69)
at com.android.tools.idea.gradle.structure.editors.AndroidProjectSettingsService.openModuleSettings(AndroidProjectSettingsService.java:94)
at com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode.navigate(PsiDirectoryNode.java:286)
at com.intellij.util.OpenSourceUtil.navigate(OpenSourceUtil.java:83)
at com.intellij.util.OpenSourceUtil.navigate(OpenSourceUtil.java:58)
at com.intellij.util.OpenSourceUtil.navigate(OpenSourceUtil.java:51)
at com.intellij.ide.actions.BaseNavigateToSourceAction.actionPerformed(BaseNavigateToSourceAction.java:24)
at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:258)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:275)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:287)
at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:283)
at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:106)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:277)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:111)
at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
at com.intellij.openapi.application.TransactionGuardImpl.lambda$submitTransaction$1(TransactionGuardImpl.java:111)
at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:120)
at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)
at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:111)
at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:524)
at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:35)
at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMenuDragMouseHandler.menuDragMouseReleased(BegMenuItemUI.java:578)
at javax.swing.JMenuItem.fireMenuDragMouseReleased(JMenuItem.java:586)
at javax.swing.JMenuItem.processMenuDragMouseEvent(JMenuItem.java:483)
at javax.swing.JMenuItem.processMouseEvent(JMenuItem.java:429)
at javax.swing.MenuSelectionManager.processMouseEvent(MenuSelectionManager.java:329)
at javax.swing.plaf.basic.BasicPopupMenuUI$MouseGrabber.eventDispatched(BasicPopupMenuUI.java:870)
at java.awt.Toolkit$SelectiveAWTEventListener.eventDispatched(Toolkit.java:2430)
at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2322)
at java.awt.Toolkit$ToolkitEventMulticaster.eventDispatched(Toolkit.java:2321)
at java.awt.Toolkit.notifyAWTEventListeners(Toolkit.java:2280)
at java.awt.Component.dispatchEventImpl(Component.java:4799)
at java.awt.Container.dispatchEventImpl(Container.java:2295)
at java.awt.Component.dispatchEvent(Component.java:4725)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
at java.awt.Container.dispatchEventImpl(Container.java:2281)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4725)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
at java.awt.EventQueue.access$500(EventQueue.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:715)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:737)
at java.awt.EventQueue$4.run(EventQueue.java:735)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:719)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:664)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:363)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.Throwable
at com.intellij.openapi.util.objectTree.ObjectTree.executeAll(ObjectTree.java:143)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:129)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:125)
at com.intellij.openapi.roots.impl.libraries.LibraryTableBase.commit(LibraryTableBase.java:183)
at com.intellij.openapi.roots.impl.libraries.LibraryTableBase.access$600(LibraryTableBase.java:29)
at com.intellij.openapi.roots.impl.libraries.LibraryTableBase$LibraryModel.commit(LibraryTableBase.java:224)
I am trying to modify the project in a facet configuration, is that wrong?