dkandalov / live-plugin

IntelliJ plugin for writing IntelliJ plugins at runtime ⚡️
https://plugins.jetbrains.com/plugin/7282
Apache License 2.0
858 stars 67 forks source link

.live-plugins does not appear to work in Android Studio #138

Closed matejdro closed 2 years ago

matejdro commented 2 years ago

Not sure if I'm doing something wrong here. My goal is to have a per-project custom plugin. So I've tried creating .live-plugins folder and putting simple hello world plugin into it:

image

But plugin does not appear to get loaded after I restart the IDE and reopen the project.

This is with

Android Studio Dolphin | 2021.3.1 Beta 5
Build #AI-213.7172.25.2113.8774922, built on June 28, 2022
Runtime version: 11.0.14.1+1-b2043.45 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
LivePlugin (0.7.3 beta)
Linux

From what I can see, 0.7.3 beta is pretty old, but this is the latest one I see through official plugin marketplace.

This is the only LivePlugin-related idea.log entry and I'm not sure if it is relevant in this case:

Please do not use ActionPlaces.UNKNOWN or the empty place. Any string unique enough to deduce the toolbar location will do. 
java.lang.Throwable: toolbar creation trace
    at com.intellij.openapi.actionSystem.impl.ActionToolbarImpl.<init>(ActionToolbarImpl.java:115)
    at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.createActionToolbar(ActionManagerImpl.java:427)
    at com.intellij.openapi.actionSystem.impl.ActionManagerImpl.createActionToolbar(ActionManagerImpl.java:422)
    at liveplugin.IdeUtil$MyConsolePanel.<init>(IdeUtil.kt:103)
    at liveplugin.IdeUtil$showInConsole$runnable$1.invoke(IdeUtil.kt:85)
    at liveplugin.IdeUtil$showInConsole$runnable$1.invoke(IdeUtil.kt:38)
    at liveplugin.IdeUtilKt$sam$java_lang_Runnable$0.run(IdeUtil.kt)
    at com.intellij.openapi.application.impl.ApplicationImpl.invokeAndWait(ApplicationImpl.java:437)
    at liveplugin.IdeUtil.showInConsole(IdeUtil.kt:97)
    at liveplugin.IdeUtil.displayError(IdeUtil.kt:57)
    at liveplugin.pluginrunner.RunPluginActionsKt.displayError(RunPluginActions.kt:176)
    at liveplugin.pluginrunner.RunPluginActionsKt.runWith(RunPluginActions.kt:72)
    at liveplugin.pluginrunner.RunPluginActionsKt.access$runWith(RunPluginActions.kt:1)
    at liveplugin.pluginrunner.RunPluginAction$Companion.runPlugins(RunPluginActions.kt:44)
    at liveplugin.LivePluginProjectListener.projectOpened(LivePluginProjectListener.kt:33)
    at com.intellij.util.messages.impl.MessageBusImpl.invokeMethod(MessageBusImpl.java:645)
    at com.intellij.util.messages.impl.MessageBusImpl.invokeListener(MessageBusImpl.java:624)
    at com.intellij.util.messages.impl.MessageBusImpl.access$300(MessageBusImpl.java:33)
    at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.executeOrAddToQueue(MessageBusImpl.java:208)
    at com.intellij.util.messages.impl.CompositeMessageBus$ToDirectChildrenMessagePublisher.publish(CompositeMessageBus.java:105)
    at com.intellij.util.messages.impl.MessageBusImpl$MessagePublisher.invoke(MessageBusImpl.java:166)
    at com.sun.proxy.$Proxy112.projectOpened(Unknown Source)
    at com.intellij.openapi.project.impl.ProjectManagerExImplKt$openProject$1.run(ProjectManagerExImpl.kt:468)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
    at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeAndWait$7(ApplicationImpl.java:450)
    at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:134)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
    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:891)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
    at com.intellij.ide.IdeEventQueue.pumpEventsForHierarchy(IdeEventQueue.java:951)
    at com.intellij.openapi.progress.util.ProgressWindow.lambda$startBlocking$6(ProgressWindow.java:221)
    at com.intellij.openapi.application.impl.ApplicationImpl.runUnlockingIntendedWrite(ApplicationImpl.java:831)
    at com.intellij.openapi.progress.util.ProgressWindow.startBlocking(ProgressWindow.java:217)
    at com.intellij.openapi.progress.impl.ProgressRunner.lambda$execFromEDT$6(ProgressRunner.java:321)
    at java.base/java.util.concurrent.CompletableFuture.uniAcceptNow(CompletableFuture.java:753)
    at java.base/java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:731)
    at java.base/java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2108)
    at com.intellij.openapi.progress.impl.ProgressRunner.execFromEDT(ProgressRunner.java:318)
    at com.intellij.openapi.progress.impl.ProgressRunner.submit(ProgressRunner.java:259)
    at com.intellij.openapi.progress.impl.ProgressRunner.submitAndGet(ProgressRunner.java:185)
    at com.intellij.openapi.project.impl.ProjectUiFrameAllocator.run(ProjectFrameAllocator.kt:116)
    at com.intellij.openapi.project.impl.ProjectManagerExImpl.doOpenAsync(ProjectManagerExImpl.kt:119)
    at com.intellij.openapi.project.impl.ProjectManagerExImpl.openProjectAsync(ProjectManagerExImpl.kt:110)
    at com.intellij.ide.RecentProjectsManagerBase.openProject(RecentProjectsManagerBase.kt:328)
    at com.intellij.ide.ReopenProjectAction.actionPerformed(ReopenProjectAction.java:69)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:239)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:260)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:239)
    at com.intellij.openapi.wm.impl.welcomeScreen.RecentProjectPanel.performSelectedAction(RecentProjectPanel.java:208)
    at com.intellij.openapi.wm.impl.welcomeScreen.RecentProjectPanel$1.onClick(RecentProjectPanel.java:116)
    at com.intellij.ui.ClickListener$1.mouseReleased(ClickListener.java:59)
    at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:298)
    at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
    at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:297)
    at java.desktop/java.awt.Component.processMouseEvent(Component.java:6654)
    at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345)
    at java.desktop/java.awt.Component.processEvent(Component.java:6419)
    at java.desktop/java.awt.Container.processEvent(Container.java:2263)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5029)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
    at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
    at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
    at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
    at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2793)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4861)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
    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.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
    at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
    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:748)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
    at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:820)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:757)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:498)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
dkandalov commented 2 years ago

I think the plugin code should be in .live-plugins/hello/plugin.kts, i.e. in a subfolder and in plugin.kts which is an entry point by convention.

Having to use a subfolder is a bit confusing and might be worth fixing so that plugin.kts can be at the root. Using any file name as a plugin entry point is more questionable because right now it's possible to have plugin source code in multiple files with plugin.kts being executed when plugin is loaded.

matejdro commented 2 years ago

Thanks, it worked!

I don't think a fix for that is really needed. Instead, documenting this in the README would probably be helpful.