Can I write Eclipse plugins using Groovy?
Groovy开发者_如何学JAVA seems to fix a lot of the things I dislike about Java, and I was wondering if it would be possible to actually write an Eclipse plugin in Groovy instead of Java.
Does anyone know if this is possible, and if so how to go about it?
I've just found a blog entry which says it's not officially supported but is actually possible.
Not yet tested to see if it works, but it seems promising:
Writing Eclipse plugins with Groovy, by Jörn Dinkla
@Peter, I do not think that the blog post you linked to is complete or if it will really work. It is pointing to the old version of Groovy-Eclipse, which is no longer supported and is out of date.
Yes. It is possible to create your own plugins in Groovy.
- First, install the Groovy-Eclipse plugin from here: http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.7/
- Then you can create a new plugin project and add the Groovy Nature.
- Remove the Groovy Libraries classpath container
- Instead, add the
org.codehause.groovy
as a required bundle - Create your Groovy code as normal
- Now, the tricky part is exporting the plugin using PDE. See this blog post for how to do that: http://contraptionsforprogramming.blogspot.com/2010/08/groovy-pde-redux.html One important thing to note is that you will need at least one Java file in your project for PDE to compile anything, It can be a dummy, empty file (this is a bug that has not yet been fixed).
- Rejoice!
As an example, here is the codenarc Eclipse plugin that was written completely in Groovy: http://sourceforge.net/projects/codenarceclipse/
You can also use JRuby, or Javascript ...
JAM Circle is a great example showing how to make great use of a scripting language in an Eclipse plugin, by allowing the end user to write his own actions and load them at runtime.
There's a proxy-like plugin that allows you to implement the plugin virtually in any language that supports JSR223 (javax.scripting)
精彩评论