views:

21

answers:

2

I'm using Eclipse and I have the Groovy Plugin installed.

From within a standard Java project I want to include a file with a .groovy extension on the runtime classpath. I have a source folder (src/main/resources) which includes all files and has no exclusion filters. Inside that directory I have 2 files: foo.groovy and foo.txt. When I clean and rebuild the project from eclipse and look in the output directory I see foo.txt, but foo.groovy is nowhere to be found.

Does anyone know if it's possible to have Eclipse treat a file with a .groovy extension like any other resource file while still having the Groovy plugin installed and having other Groovy projects in the same workspace?

In case you are wondering, I'm trying to get logback configured using a groovy script. If there's some other way to accomplish this please let me know.

+1  A: 

I ran into the same thing a few years ago. The Groovy plugin treats .groovy files as source files. The same way a .java files do not get put into the output directory, neither do .groovy files. At the time I could not find a way around this. I don't know if there is a way around it but I did come up with a workaround.

I used the extension .g for groovy files that I wanted to keep as scripts and have them interpreted at runtime. These would be skipped by the groovy compiler and would end up in the output directory. Also doing things this way allows you to mix compiled groovy (.groovy) and runtime interpreted groovy files (.g).

Chris Dail
The only issue with this in my particular case is that logback expects a file named "logback.groovy". I'm pretty much convinced there's no good work around for this so I've disabled the plugin.
Mike Deck