You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Ritu Kedia <ri...@mphasis.com> on 2007/07/18 08:20:18 UTC

FW: Choice of implementation language for writing Maven2 Plugins

Hi,
 
Forwarding this message to the Maven Developers to get the insiders views on
the choice of implementation language for writing Maven2 Plugins (Please
read my mail below). Your reply will be very much appreciated. I have tried
searching the mailing list archives but haven't found a relevant discussion
thread on similar topic.
 
Thanks,
Ritu

  _____  

From: Ritu Kedia [mailto:ritu.kedia@mphasis.com] 
Sent: Tuesday, July 17, 2007 7:14 PM
To: 'users@maven.apache.org'
Subject: Choice of implementation language for writing Maven2 Plugins


Hi,
 
We are currently investigating the implementation language for writing
Maven2 Plugins. 
We have looked at all the 3 options available today in Maven2, namely:
- Java
- Ant Scripting
- Scripting Languages (looked at Beanshell, Groovy, JRuby)
 
Our parameters for evaluation are:
- Maturity of the platform
- Ease of Development 
- Ease of Maintenance
- Performance 
- Available set of tools/libraries required for Plugin development
 
Based on our analysis/requirements we have reduced our choice of
implementation language to:
Java OR Groovy
 
In terms of Performance, Java would beat the scripting options by a big
percentage. However for build activities, which involve heavy Disk IO tasks,
the performance comparisons would have to be looked at differently. For
instance we compared the performance of a pre-compiled Groovy script with
Java where both of them issued 100 Copy statements on a directory containing
10 files of 10KB each and both Groovy and Java used the same Java libraries
to do the Copy. The execution times were almost on par. We would like to
know if others have done similar profiling and have results/experience that
they can share. Performance is an important factor in our decision making
and so any comments on this would be much appreciated.
 
In terms of Maturity, Groovy is yet to come up the mark. But given that it
is in the process of being standardized as the sanctioned scripting language
on Java Platform (JSR-241), I would expect it to be a safe bet.
 
In terms of Ease of Development and Available set of tools/libraries for
Plugin development, Groovy's AntBuilder seems to be a very attractive
option. We have also taken a look at the available Maven Plexus Utilities
for the same. Firstly the documentation for Plexus utilities is poor and
secondly but more importantly the available set of Plexus utilities do not
match up to the Ant utilties/tasks. Secondly we are talking about build
tasks, most of which are already available in Ant and are very well
documented and tested. Thirdly Groovy's AntBuilder provides a declarative
syntax for defining Ant tasks and makes the scripts much more concise and
readable. Finally Groovy provides us the power of a programming language
along with declarative Ant inclusion. These factors coupled with the fact
that we are basically migrating our existing jelly scripts that use ant
heavily and have so far sufficed for all our requirements, to Maven MOJOs
makes Groovy more attractive than Java. I am really interested to know the
views of people on Groovy vs Java for writing build tasks.
 
Also I saw that the Groovy MOJO support is in alpha release. When is it
expected to be available as a stable release? What is Maven team's overall
push and direction in promoting Groovy as the standard scripting language.
 
Thanks in advance,
Ritu
 
 

Re: Choice of implementation language for writing Maven2 Plugins

Posted by Jason Dillon <ja...@planet57.com>.
Comments inline...

> Based on our analysis/requirements we have reduced our choice of
> implementation language to:
> Java OR Groovy

Personally, I prefer Groovy for most mojo things these days, though  
there are some cases where you need to mix in some plain Java classes  
for performance, like if you need a custom class loader or something.


> In terms of Performance, Java would beat the scripting options by a  
> big
> percentage. However for build activities, which involve heavy Disk  
> IO tasks,
> the performance comparisons would have to be looked at differently.  
> For
> instance we compared the performance of a pre-compiled Groovy  
> script with
> Java where both of them issued 100 Copy statements on a directory  
> containing
> 10 files of 10KB each and both Groovy and Java used the same Java  
> libraries
> to do the Copy. The execution times were almost on par. We would  
> like to
> know if others have done similar profiling and have results/ 
> experience that
> they can share. Performance is an important factor in our decision  
> making
> and so any comments on this would be much appreciated.

For the most part you won't really notice any major performance  
issues with plugins implemented in Groovy.  There are a couple of  
ways to roll them, but the preferred method is to compile the .groovy  
bits into .class files during the plugin artifact generation, and  
then the code runs as normal Java in the Maven container.

Groovy code will execute slightly slower than plain Java, but we are  
talking about a fraction of a second, and for most build needs you  
won't even notice it.  One of the really nice things about Groovy is  
that you can freely mix/match Java and Groovy code so you can use  
Java where performance counts and then use Groovy for ease of  
development.  Only caveat right now is that you need to make sure  
that Groovy code depends on Java code and Java code in the same  
module does not depend on Groovy code.  If you need to have the Java  
code depend on Groovy, then best to make a Java interface to abstract  
it.  The next release of the Maven 2 integration should support the  
new joint complier in Groovy 1.1 which will make this a non-issue.


> In terms of Maturity, Groovy is yet to come up the mark. But given  
> that it
> is in the process of being standardized as the sanctioned scripting  
> language
> on Java Platform (JSR-241), I would expect it to be a safe bet.

Groovy is definitely younger than Java, but Groovy 1.0 has been out  
for a while and the syntax has stabilized greatly.  The latest Groovy  
1.1-beta-2 is always quite stable, mostly new features added,  
optimizations and other goodies.  A year ago (or 2) I might not have  
the same opinion, but today I think that Groovy is a very viable  
solution for Maven plugin development, as for other development too.


> In terms of Ease of Development and Available set of tools/ 
> libraries for
> Plugin development, Groovy's AntBuilder seems to be a very attractive
> option. We have also taken a look at the available Maven Plexus  
> Utilities
> for the same. Firstly the documentation for Plexus utilities is  
> poor and
> secondly but more importantly the available set of Plexus utilities  
> do not
> match up to the Ant utilties/tasks. Secondly we are talking about  
> build
> tasks, most of which are already available in Ant and are very well
> documented and tested. Thirdly Groovy's AntBuilder provides a  
> declarative
> syntax for defining Ant tasks and makes the scripts much more  
> concise and
> readable. Finally Groovy provides us the power of a programming  
> language
> along with declarative Ant inclusion. These factors coupled with  
> the fact
> that we are basically migrating our existing jelly scripts that use  
> ant
> heavily and have so far sufficed for all our requirements, to Maven  
> MOJOs
> makes Groovy more attractive than Java.

Groovy's AntBuilder kicks ass... <period>.  This is one of the most  
compelling reasons IMO for developing Maven plugins with Groovy.  The  
others I think come in close behind are GJDK methods (mostly the each  
methods I use all the time) and closures.

The only significant problem that I've run into so far has been the  
last of nested and anonymous classes... which can be worked around,  
but still is quite annoying for Java developers who are used to using  
them.

> I am really interested to know the
> views of people on Groovy vs Java for writing build tasks.

Well, for me... I'm trying to use Groovy as much as possible for  
Maven plugins... partly to make sure that the Maven 2/Groovy  
integration is solid and complete, but also because I find that  
Groovy plugins are much more terse and easier to grok.... and less  
typing means less code for me to maintain ;-)


> Also I saw that the Groovy MOJO support is in alpha release. When  
> is it
> expected to be available as a stable release?

1.0-beta-1 of the Groovy Maven 2 integration is going to be released  
tomorrow, though the 1.0-alpha-3 release is already quite usable and  
its configuration syntax is relatively stable.  I imagine that 1.0  
will be released around the same that that Groovy 1.1 is released,  
which should be sometime later this year.  I'm working on pushing out  
updates to the Maven 2 integration every month or so depending on  
time and features to be added.

There are already several plugins hosted at the Mojo project which  
are implemented using the Groovy integration, like the selenium-maven- 
plugin, retrotranslator-maven-plugin, jspc-maven-plugin (v2).  I've  
heard some reports of other plugins using it as well.  I'll probably  
add a list to the site docs so folks can peek at how the integration  
is being used.


> What is Maven team's overall
> push and direction in promoting Groovy as the standard scripting  
> language.

I'm also interested in what the Maven teams has to say about Groovy  
too :-)

Cheers,

--jason



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org