Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » [PDE-Build] Build Groovy files
[PDE-Build] Build Groovy files [message #649966] Fri, 21 January 2011 09:06 Go to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Hi all,

I am more and more thinking to write some pieces of code in Groovy, aainly in my test plug-ins. That would reduce the cost of writing tests for the same coverage as Java.
I gave it a try yesterday, and could successfully integrate a Groovy class to a plug-in which had the Groovy nature enabled. So that I could run my Groovy test in my development workbench. The Groovy builder automatically generated me the .class file for my .groovy file, and I could use it in the uitestapplication. Good.

It became more complicated when I tried to use this test in headless build. Indeed, it seems that the headless build did not invoke the Groovy builder so that the .class was not generated. Before this event, I thought that the PDE-Build was relying on the JDT compiler, so that the Groovy compilation would be automatically triggered in automated build. But it seems that it is not the case.
An alternative would be to tweak the plug-in's build.xml to add a groovyc task, but that's not straightforward.

Are there any easier workarounds to get it working? Are there plans to make PDE-build extensible to allow JDT extensions such as Groovy-Eclipse to add their steps at compile-time?

Thanks in advance.
--
Mickael Istria -- BonitaSoft S.A.
http://www.bonitasoft.com/products/BPM_download.php
Re: [PDE-Build] Build Groovy files [message #650455 is a reply to message #649966] Tue, 25 January 2011 02:18 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
Yes, PDE build does use the JDT compiler, but the problem is that the ant Javac task only recognizes *.java files (hard coded). I created a workaround for groovy files with Groovy-Eclipse installed. See here:

http://contraptionsforprogramming.blogspot.com/2010/08/groov y-pde-redux.html
Re: [PDE-Build] Build Groovy files [message #650548 is a reply to message #650455] Tue, 25 January 2011 13:37 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Thanks a lot for this workaround Andrew, it works like a charm!
I saw the Ant bug is fixed. Does that mean that this workaround is no more necessary when using the org.apache.ant_1.8.2 bundles in build platform?

Le 25/01/2011 03:18, Andrew Eisenberg a écrit :
> Yes, PDE build does use the JDT compiler, but the problem is that the ant Javac task only recognizes *.java files (hard coded). I created a workaround for groovy files with Groovy-Eclipse installed. See here:
>
> http://contraptionsforprogramming.blogspot.com/2010/08/groov y-pde-redux.html


--
Mickael Istria -- BonitaSoft S.A.
http://www.bonitasoft.com/products/BPM_download.php
Re: [PDE-Build] Build Groovy files [message #650560 is a reply to message #650548] Tue, 25 January 2011 14:20 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
The ant bug is fixed, yes. I am not sure if this version is being used in platform yet...it may for 3.6.2, I haven't checked.

But even if it is, you will still need the work around, it will just mean that I can refactor the workaround so that it will be simpler and there will be no unnecessary warnings.
Re: [PDE-Build] Build Groovy files [message #650792 is a reply to message #650560] Wed, 26 January 2011 15:16 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Le 25/01/2011 15:20, Andrew Eisenberg a écrit :
> The ant bug is fixed, yes. I am not sure if this version is being used in platform yet...it may for 3.6.2, I haven't checked.

You can get org.apache.ant_1.8.2 from Orbit, and I think there is no problem to use this one rather that the 1.7.1 in older Eclipse releases.

> But even if it is, you will still need the work around, it will just mean that I can refactor the workaround so that it will be simpler and there will be no unnecessary warnings.

Ok, isn't the JDTCompilerAdapter extensible? so that one can only plus some additional steps to this adapter, and headless build could benefit of all other JVM languages support that extended it without tweaks? That would be very cool!

--
Mickael Istria -- BonitaSoft S.A.
http://www.bonitasoft.com/products/BPM_download.php
Re: [PDE-Build] Build Groovy files [message #650884 is a reply to message #650792] Thu, 27 January 2011 02:25 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
> Ok, isn't the JDTCompilerAdapter extensible? so that one can only plus some additional steps to this adapter, and headless build could benefit of all other JVM languages support that extended it without tweaks? That would be very cool!

That's basically right. With the ant bug patched, you can create a Compiler adapter for groovy like this (much simpler than what is shipped with Groovy-Eclipse, but the same basic functionality):

public class GroovyCompilerAdapter extends JDTCompilerAdapter implements CompilerAdapterExtension {
  public String[] getSupportedFileExtensions() {
    return new String[]  { "*.java", "*.groovy" };
  }
}


You also need to edit your build.properties file as described in the blog post, but you can skip specifying the file extensions a second time.

I haven't tested this out, but it should work. Let me know if you try it.
Re: [PDE-Build] Build Groovy files [message #650949 is a reply to message #650884] Thu, 27 January 2011 09:26 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

> That's basically right. With the ant bug patched, you can create a Compiler adapter for groovy like this (much simpler than what is shipped with Groovy-Eclipse, but the same basic functionality):
>
>
> public class GroovyCompilerAdapter extends JDTCompilerAdapter implements CompilerAdapterExtension {
> public String[] getSupportedFileExtensions() {
> return new String[] { "*.java", "*.groovy" };
> }
> }
>
>
> You also need to edit your build.properties file as described in the blog post, but you can skip specifying the file extensions a second time.

What I have in mind is more a JDTCompilerAdapter that would come with an extension point to add support for other extensions, then there wouldn't have anything to change in build.properties, and PDE-build would be able to build Groovy whenever the extension for .groovy files is present in the platform.
Or to have a ExtensibleDispatcherCompilerAdapter that would dispatch the compile steps to several CompilerAdapter (eg JDT, Groovy) according to their extension.

That way, we could imagine to have plugin in any JDT-friendly language, and to have polyglot bundles without other effort than installing a new language support in Eclipse. This would allow people to write bundles in most of JVM languages. (currently Java, Groovy, Scala; and probably Clojure, Jython and so on in the future...).

--
Mickael Istria -- BonitaSoft S.A.
http://www.bonitasoft.com/products/BPM_download.php
Re: [PDE-Build] Build Groovy files [message #651020 is a reply to message #650949] Thu, 27 January 2011 13:27 Go to previous messageGo to next message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
Mickael Istria wrote on Thu, 27 January 2011 04:26
>What I have in mind is more a JDTCompilerAdapter that would come with an extension point to add support for other extensions, then there wouldn't have anything to change in build.properties, and PDE-build would be able to build Groovy whenever the extension for .groovy files is present in the platform.
Or to have a ExtensibleDispatcherCompilerAdapter that would dispatch the compile steps to several CompilerAdapter (eg JDT, Groovy) according to their extension.


It doesn't work like that really. Groovy uses an extended JDT compiler, but Scala and AspectJ do not (I don't know about other languages, though). This means that Scala and AspectJ cannot use the the JDTCompilerAdapter. Rather they must use a compiler adapter that delegates to their own compiler.

The AspectJ compiler is not compatible with the Groovy-Eclipse compiler, which is not compatible with the Scala compiler. This is why you cannot have a project in Eclipse that contains more than one of these languages at the same time.
Re: [PDE-Build] Build Groovy files [message #651021 is a reply to message #651020] Thu, 27 January 2011 13:29 Go to previous message
Andrew Eisenberg is currently offline Andrew EisenbergFriend
Messages: 382
Registered: July 2009
Senior Member
But, this does make me think of one way that this can be easier. Since we are patching JDT to release wth Groovy-Eclipse, we can patch the compiler adapter as well so that for plugin developers, it is transparent to compile Groovy code (ie- no need for augmenting the buld.properties).
Previous Topic:Adding libraries to eclipse pluggings
Next Topic:Integration of Findbugs into PDE build
Goto Forum:
  


Current Time: Thu Apr 25 00:36:30 GMT 2024

Powered by FUDForum. Page generated in 0.03255 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top