Using M2Eclipse together with Groovy

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Using M2Eclipse together with Groovy

RoesslerWolfgang
Hello,

I am currently developing a project where I am using java together with groovy. Has anyone tried this?
I stumbled across the following problems:
- I place my scripts in src/main/groovy and when I run "Update Project Configuration" the source-folder gets removed again. I guess M2Eclipse is not aware of Groovy?
- I wanted to set the output-directory of the groovy plugin to target/classes, I get the following error "Source folder 'src/main/java' in project 'mdm-devtools.ea-docgen' cannot output to library 'target/classes'"

Can anyone help me?

Greets
Wolfgang
Reply | Threaded
Open this post in threaded view
|

Re: Using M2Eclipse together with Groovy

Eugene Kuleshov
Wolfgang,

  To make it work right, you would need additional project configurator
specific to your Groovy tools. Eg. it should read configuration of
Groovy plugins and configure Groovy project in Eclipse accordingly. You
may want to contact authors of your Groovy tools for Eclipse and point
them to project configurators for m2eclipse [1].

  regards,
  Eugene

[1]
http://docs.codehaus.org/display/M2ECLIPSE/Extensible+project+configuration+framework


WolfgangRoessler wrote:

> Hello,
>
> I am currently developing a project where I am using java together with
> groovy. Has anyone tried this?
> I stumbled across the following problems:
> - I place my scripts in src/main/groovy and when I run "Update Project
> Configuration" the source-folder gets removed again. I guess M2Eclipse is
> not aware of Groovy?
> - I wanted to set the output-directory of the groovy plugin to
> target/classes, I get the following error "Source folder 'src/main/java' in
> project 'mdm-devtools.ea-docgen' cannot output to library 'target/classes'"
>
> Can anyone help me?
>
> Greets
> Wolfgang
>  



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Using M2Eclipse together with Groovy

Eric Sword
For anyone else who stumbles on this thread and wants to know how to get groovy and maven working together, here are the steps I figured out for some projects I had.  Your mileage may vary if you have some other custom setup:

When you import a maven project that has groovy files, the Eclipse groovy plugin may or may not detect the groovy files and automatically prompt you to add the Groovy Nature to the project. If it does not, once the import is complete, select the project in the Navigator or Package Explorer, right click, and select Add Groovy Nature. You will then need to make a few adjustments to get groovy, m2eclipse, and the eclipse built-in compiler all looking in the right places:

1. Open the Project Properties dialog. In the Groovy Project Properties pane, change the groovy compiler output to be target/classes (i.e. the default for the project). Click okay to close the dialog. It will spin for a while as it rebuilds things.
2. You will eventually see an error like this: Source folder 'src/main/java' in project '<project name>' cannot output to library 'target/classes'.
3. Open the Project Properties dialog again and select the Java Build Path pane. Under the source tab, you will see that each source directory has one of two custom output directories, target/classes and target/test-classes. This is the standard maven setup. You will also see that the default output directory for the project is target/classes.
4. Change any Source directory that has an output directory that is the same as the default (i.e. any that are causing the error listed above) to just use the project default.  There may be more than one, and the OK button will not highlight until all errors have been cleared.
5. Add the groovy source directories if they are not already listed. Let src/main/groovy have the default output directory. Set the output for src/test/groovy to target/test-classes.
6. Click OK to close the dialog.

The project should now clean itself and eventually compile all the groovy files as it would in a non-maven eclipse project with groovy files. If you have mixed java-groovy dependencies (i.e. a java class imports a groovy class, or visa-versa), you may need to "touch" (add a space and then remove it) one or more of the groovy files to get it to be properly recognized.  This is a normal problem with the eclipse-groovy integration. I have not been able to determine if the ordering of the <buildCommand> or <nature> tags in the .project file makes any difference for avoiding this issue. Luckily, you normally only need to do the "touch" when a project has just been cleaned.

Reply | Threaded
Open this post in threaded view
|

Re: Using M2Eclipse together with Groovy

lukewpatterson
This post has NOT been accepted by the mailing list yet.
Eric Sword wrote
For anyone else who stumbles on this thread and wants to know how to get groovy and maven working together, here are the steps I figured out for some projects I had.  Your mileage may vary if you have some other custom setup:
Does anyone know if there has been progress in this area?  I'd like to be able to use M2Eclipse to work with a Groovy-based project.