在Intellij / IDEA插件中以编程方式调用Ant目标

时间:2016-03-28 05:37:35

标签: intellij-idea codenameone intellij-plugin

我正在尝试根据插件中的用户操作调用ant目标。这样做曾经工作:

AntConfiguration conf = AntConfiguration.getInstance(project);

我的plugin.xml包含条目:

<depends optional="false">AntSupport</depends>

如上所述here

但是,使用当前版本的IntelliJ会抛出此异常:

  

java.lang.ClassCastException:   com.intellij.lang.ant.config.impl.AntConfigurationImpl无法强制转换   com.intellij.lang.ant.config.AntConfiguration at   com.intellij.lang.ant.config.AntConfiguration.getInstance(AntConfiguration.java:38)     在   com.codename1.plugin.intellij.ant.AntRunner.getAntFile(AntRunner.java:133)     在   com.codename1.plugin.intellij.ant.AntRunner.runTarget(AntRunner.java:59)     在   com.codename1.plugin.intellij.actions.CodenameOneAction.runAntTarget(CodenameOneAction.java:61)     在   com.codename1.plugin.intellij.actions.SendAndroidBuild.actionPerformed(SendAndroidBuild.java:17)     在   com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:191)     在   com.intellij.openapi.actionSystem.impl.ActionMenuItem $ ActionTransmitter $ 1.run(ActionMenuItem.java:311)     在   com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:958)     在   com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:124)     在   com.intellij.openapi.actionSystem.impl.ActionMenuItem $ ActionTransmitter.actionPerformed(ActionMenuItem.java:281)     在   javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)     在   com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:109)     在   com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:513)     在   com.intellij.ui.plaf.beg.BegMenuItemUI.access $ 300(BegMenuItemUI.java:45)     在   com.intellij.ui.plaf.beg.BegMenuItemUI $ MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:533)     在java.awt.Component.processMouseEvent(Component.java:6525)at   javax.swing.JComponent.processMouseEvent(JComponent.java:3324)at   java.awt.Component.processEvent(Component.java:6290)at   java.awt.Container.processEvent(Container.java:2234)at   java.awt.Component.dispatchEventImpl(Component.java:4881)at   java.awt.Container.dispatchEventImpl(Container.java:2292)at   java.awt.Component.dispatchEvent(Component.java:4703)at   java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)     在   java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)     在java.awt.Container.dispatchEventImpl(Container.java:2278)at   java.awt.Window.dispatchEventImpl(Window.java:2750)at   java.awt.Component.dispatchEvent(Component.java:4703)at   java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)at at   java.awt.EventQueue.access $ 500(EventQueue.java:97)at   java.awt.EventQueue $ 3.run(EventQueue.java:709)at   java.awt.EventQueue $ 3.run(EventQueue.java:703)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)     在   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:86)     在java.awt.EventQueue $ 4.run(EventQueue.java:731)at   java.awt.EventQueue $ 4.run(EventQueue.java:729)at   java.security.AccessController.doPrivileged(Native Method)at   java.security.ProtectionDomain $ 1.doIntersectionPrivilege(ProtectionDomain.java:75)     在java.awt.EventQueue.dispatchEvent(EventQueue.java:728)at   com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:857)     在   com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:654)     在   com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:386)     在   java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)     在   java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)     在   java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)     在   java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)     在java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

对我来说这看起来像个错误,但我可能会以某种方式滥用API,因为据我所知,这并没有完全“记录”。

1 个答案:

答案 0 :(得分:0)

好的,想出这个。我忽略了将库依赖项设置为提供状态并使它们处于“已编译”状态。这有点隐藏在依赖窗口中:

enter image description here