maven compile groovy

Jeff Storey picture Jeff Storey · Jun 20, 2009 · Viewed 9k times · Source

I have a situation where some of my groovy code references my java files, but I also have different java files that reference the same groovy code. When trying to compile in maven, I either need to compile the groovy before or after the java, and that won't really work since the groovy code depends on some java files, and different java files depend on the groovy code. Is there a way to handle this sort of dependency?

Answer

Robert Munteanu picture Robert Munteanu · Jun 20, 2009

Yes, just use GMaven. Since it's a joint compiler, it automatically manages your java to groovy and groovy to java dependencies.

Briefly, you will need to:

  • include the gmaven-plugin in your pom.xml;
  • keep your groovy classes under src/main/groovy or src/test/groovy;
  • bind the gmaven plugin to the relevant lifecycle phases.

For more details see building groovy projects.