Issues with accessing AntConfiguration
I am writing a plugin that will do continuous integration using ant. I am using the VFS to detect changes and running a user-defined AntBuildFile along with a user-defined AntBuildTarget
In my action class where I register a listener I start off by retrieving the list of Ant Build Files registered by the user:
36 Project project = e.getData(PlatformDataKeys.PROJECT);
37 AntBuildFile[] buildFiles = AntConfiguration.getInstance(project).getBuildFiles();
On line 37 I get a class cast exception complaining that I cannot castc AntConfigurationImpl to AntConfiguration with the following message with a brief stack trace shown.
java.lang.ClassCastException: com.intellij.lang.ant.config.impl.AntConfigurationImpl cannot be cast to com.intellij.lang.ant.config.AntConfiguration
at com.intellij.lang.ant.config.AntConfiguration.getInstance(AntConfiguration.java:37)
at com.cetova.intellij.plugin.autoant.HelloWorld3.actionPerformed(HelloWorld3.java:32)
I am using 11.0.2 Build #IU-111.277 on a windows server 2008 R2
I am also using the AntIntegration.jar I found in the Intellij Plugins directory.
Any help you can provide would be most appreciated.
Thanks,
Ira
请先登录再写评论。
The plugin jar must be added to the classpath of the IntelliJ IDEA SDK, not as a separate library.
Dmitry,
Thank you for the quick response, I've seen this suggestion in another forum post and I unfortunately get a different error. I just tried it again now and here is the detailed information on the error:
I have added these 2 jars to the SDK: IDEA IU-111.277 in the ProjectStruture dialog
{Intellij.install.location}\plugins\ant\lib\antIntegration.jar
{Intellij.install.location}\plugins\ant\lib\resources_en.jar
This is shown in the attachment: intellij-ant.png
I then debug my plugin with my predefined Debug for my plugin.
After the program launches a new IntelliJ instance my plugin runs with the following error:
[ 58182] ERROR - com.intellij.ide.IdeEventQueue - Error during dispatching of java.awt.event.MouseEvent[MOUSE_RELEASED,(614,54),absolute(2661,197),button=1,modifiers=Button1,clickCount=1] on frame0
java.lang.NoClassDefFoundError: com/intellij/lang/ant/config/AntConfiguration
at com.cetova.intellij.plugin.autoant.HelloWorld3.actionPerformed(HelloWorld3.java:38)
With line 38 being:
38 AntBuildFile[] buildFiles = AntConfiguration.getInstance(project).getBuildFiles();
Attachment(s):
intellij-ant.png
Please make sure the Ant plugin is enabled in the instance of IntelliJ IDEA that you run under the debugger.
Still not working. I checked and the plugin is enabled on both the instance that I run under the debugger and the instance that's launched by the debugger.
Any information you need that will help please feel free to ask: screenshots, logs, join.me/webex/gotomeeting etc...
Thanks again for your help Dmitry I appreciate it.
Thanks
Ira
Dmitry,
I have got it to work, thanks for your help. I am new to the plugin architecture. I had to add a <depends> element to the plugin.xml
Here is a recap of what I did for any other person having the same issue:
1) Do NOT add antIntegration.jar or antSupport.jar (depending on IDEA version) to the dependencies under module settings
2) Add the antIntegration.jar or antSupport.jar (depending on IDEA version) to the SDK for the plugin module/project.
3) Edit your plugin.xml and add below the root xml node a depends element with: <depends optional="false">AntSupport</depends>
4) Make sure IntelliJ has AntSupport enabled
Thanks again for your help and suggestions I very much appreciate it!
Ira
Hi,
I'm running into this issue too and have gone thru the steps mentioned by Ira. This used to work for our plugin in the past (circa IntelliJ 12) so I'm not sure what's going on.
OK figured it out and answered my own question here: http://stackoverflow.com/questions/36256605/invoking-an-ant-target-programmatically-in-an-intellij-idea-plugin/36259690