They are packaged as two m2eclipse projects, and it is recommended (although not necessary) to import them into Eclipse to use them.
The
groovy-eclipse-compiler
project contains the compiler integration. It is a single Java class that calls into the Groovy-enhanced JDT compiler. This maven plugin uses plexus to hook into maven's compiler plugin.The
groovy-eclipse-maven-tests
project is a very simple maven project that has a few Groovy and Java classes that interact with each other. If you want to create your own project using the Groovy-Eclipse maven integration, I would recommend starting with this sample project.Please let me know if you have any problems.
Hi Andrew,
ReplyDeleteThanks so much for the example projects.
As I was importing them I realized that I need to add the SpringSource snapshots plugins repository to the groovy-eclipse-compiler project. Otherwise I get a missing dependency for the groovy-eclipse-batch jar.
To clean up the build-helper-maven-plugin config a bit, one should probably use this config:
ReplyDeleteorg.codehaus.mojo
build-helper-maven-plugin
1.5
add-source
generate-sources
add-source
src/main/groovy
add-test-source
generate-test-sources
add-test-source
src/test/groovy
Stefan
the xml fragment was destroyed, sorry. Hopefully you see what i mean...
ReplyDeleteStefan
Stefan, if you send me the xml directly, I'll clean it up and post it.
ReplyDeleteandrew at eisenberg dot as
Just send you an email.
ReplyDeleteStefan
Thanks. Finally got around to cleaning this up.
ReplyDelete<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/groovy</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/groovy</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
I'm looking to see if I can post your archetype on the springsource maven repo.
A couple of questions:
ReplyDelete1. With m2eclipse, is it possible to get eclipse to add a classpathentry with src/test/groovy so that you can select "Update Project Configuration" and this will be performed? I noticed that build-helper-maven-plugin will help from the cli, but not inside Eclipse. Also, your example project doesn't have a src/test/groovy folder.
2. How will this project effect GMaven? Is it intended to replace it?
3. Are you planning on releasing this plugin with future versions of Groovy, eg., 1.7.5?
Thanks for your great work on this!
Apologies for not getting back to you sooner...
ReplyDelete1. This *should* work. I haven't had a chance to try this out recently. Here is a blog post that may be useful:
http://www.sonatype.com/people/2008/05/adding-additional-source-folders-to-your-maven-build/#more-615
I'll see if I can get this working, though.
In general, I think it would be better to simply use the src/main/java and src/test/java for your groovy code since that would simplify your pom.xml configuration.
2. I am not involved with the gmaven project. GMaven does provide some benefit that this approach does not yet provide. For example, with GMaven, you can choose your own compiler level.
3. Yes. I have been busy with other projects, but I plan on doing this soon.
Nice!
ReplyDeleteWhy is http://maven.springframework.org/snapshot not browsable, via Firefox for example?
Also, it looks like that repository has release artifacts (ie: groovy-eclipse-batch) as well as snapshot artifacts (ie: groovy-eclipse-compiler), yet the URL includes the word "snapshot".
Hope this helps.
@Adam,
ReplyDeleteThanks. This repository is hosted on Amazon S3, which does not allow directory browsing. There's not much I can do about that.
And regarding the messed up repository folders...I am learning my way around maven as I do this project (and previous commenters have already helped me out).
I just uploaded a new snapshot with a new version, which will hopefully make things easier to maintain from here.
The new version is 0.5.1-SNAPSHOT. Updating your pom.xml to use this plugin dependency should work and fix some problems with AST transforms not being applied:
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>0.5.1-SNAPSHOT</version>
</dependency>
http://maven.springframework.org/snapshot/org/codehaus/groovy/groovy-eclipse-compiler/0.5.1-SNAPSHOT/groovy-eclipse-compiler-0.5.1-SNAPSHOT.pom
ReplyDeletehas a bad checksum:
Downloading: http://maven.springframework.org/snapshot/org/codehaus/groovy/groovy-eclipse-compiler/0.5.1-SNAPSHOT/groovy-eclipse-compiler-0.5.1-SNAPSHOT.pom
1K downloaded (groovy-eclipse-compiler-0.5.1-SNAPSHOT.pom)
[WARNING] *** CHECKSUM FAILED - Error retrieving checksum file for org/codehaus/groovy/groovy-eclipse-compiler/0.5.1-SNAPSHOT/groovy-eclipse-compiler-0.5.1-SNAPSHOT.pom - IGNORING
I have not included any checksums with the artifacts. Is this lack preventing you from doing your work?
ReplyDeleteNope, just thought I would give you a heads up.
ReplyDeleteAlso, how can one know what version of groovy the plugin is built with on an ongoing basis?
Thanks again!
Thanks for the heads up. It is definitely something that we plan on fixing. At this point, we are unsure how we will release this maven plugin officially.
ReplyDeleteWhen we do, the release versions will likely be in step with Groovy-Eclipse (currently at 2.1.0 and using Groovy 1.7.5, which is the version that the current release is based on).
Any news on release plans for that plugin?
ReplyDeleteTried with maven 3.0.1 and it works like a charm :-)
cant wait for a release ..
Glad that it is working for you. I've been stalled with other projects for a bit and I hope to be able to return to this soon.
ReplyDeleteIs the source for v0.5.1-SNAPSHOT of the plugin available?
ReplyDeleteIs there any way to configure the groovy-eclipse-compiler in the pom? e.g. to not display warning messages etc.
Are you looking for the source of the compiler code, the source of the other libraries that it uses, or the source of the groovy compiler that it uses internally? And are you looking to have the source code available through your maven project, or do you just want to have a look at it on the side?
ReplyDeleteI'd be happy to make all the source code available (or tell you where you can find it) since everything is open source. But, making the source available as a maven artifact would be technically difficult.
As for configuring, all of the standard JDT compiler options are recognized for compiling Java code. You can see a summary here:
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm
The groovy compilation will respect some of these options, but not others (I'm not exactly sure which, but a little bit of trial and error would tell you).
If there is an option that you'd like to have, but don't see, I can probably do something about that.
At this point i am just trying to pass the "-nowarn" arg to the compiler.
ReplyDeleteWhen i cracked open the source for the 0.0.1-SNAPSHOT of the GroovyEclipseCompiler I saw the full list of options the compiler supports -- thanks for the javadoc!
However am having a little trouble passing the "-nowarn" arg to the groovy-eclipse compiler.
When i do the compiler appears to error out and at some point prints out "unrecognized option : --nowarn". I am not sure what if the extra "-" is an artifact of the message or if something is appending the additional "-" before the compile can execute. I wanted to try and hunt it down in the source.
I found the compiler source at https://svn.codehaus.org/groovy/eclipse.
What version of the compiler does groovy-eclipse-batch 0.5.1-SNAPSHOT use? Is it just a repacked snapshot of https://svn.codehaus.org/groovy/eclipse trunk?
Yes, the compiler version is just a packaged snapshot of the groovy-eclipse compiler. I forgot what version it is, but it is a couple of months old.
ReplyDeleteCan you try passing nowarn without a preceeding '-'?
Unfortunately that results in:
ReplyDeleteUnrecognized option : "null"
BTW - i am working under the assumption that this is user error.
ReplyDeleteIt may not be a user error. I'm probably not properly propagating all of the compiler options to the compiler. I'm trying to see if there is a workaround.
ReplyDeleteCan you post the snippet of your pom.xml where you use -nowarn?
ReplyDeleteI have to run out to pick up my children ... but it looks like it is the following lines from the compiler plugin:
ReplyDeleteargs.add("-" + entry.getKey());
args.add("\"" + entry.getValue() + "\"");
maven is already passing in the -nowarn option with a "-". the first line adds another "-" - turning "-nowarn" into "--nowarn". the second line then adds a String to args because the "-nowarn" option doesn't have a corresponding value.
Fixing this in the 0.0.1-SNAPSHOT source cleared up the issue.
If you could point me to the svn repo for the plugin I will submit a patch for v0.5.1-SNAPSHOT of the groovy-eclipse-plugin.
THANKS FOR YOUR HELP!
I haven't checked this code into svn yet, but you can send the patch over to me and I'll include it and get a new snapshot out in the next few days.
ReplyDeleteThanks for looking into this.
http://docs.codehaus.org/download/attachments/182255869/groovy-eclipse-for-maven.zip link is 404
ReplyDeleteWhere did that link come from? If you are looking to use the groovy-eclipse compiler for maven, see the docs here: http://groovy.codehaus.org/Groovy-Eclipse+compiler+plugin+for+Maven
ReplyDelete