File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Groovy and the fly likes Making Java Groovy: Mevn description of mixed Java/groovy projects? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Making Java Groovy: Mevn description of mixed Java/groovy projects?" Watch "Making Java Groovy: Mevn description of mixed Java/groovy projects?" New topic
Author

Making Java Groovy: Mevn description of mixed Java/groovy projects?

Rohan Bryant
Greenhorn

Joined: Jan 08, 2013
Posts: 7
I see Groovy as a significant improvement on Java, not merely because it adds syntactic sugar
and new language constructs (closures); but because in summary it makes it so much easier to
experiment with and cement a piece of code.

The thing that frustrates me is the Maven configuration of a mixed Java/Groovy projects.
Intuitively, I would segregate groovy and java artifacts into src/main/{java | groovy}.
Groovy best practices suggest otherwise: that I should treat a mixed Java/Groovy Maven project
simply as a groovy project. I am not comfortable mixing Java and groovy sources merely because
I have distinct developers handling groovy and Java.

What would you suggest?

Thanks,

rk
Kenneth A. Kousen
gunslinger & author
Ranch Hand

Joined: Sep 18, 2002
Posts: 89
    
    5
Nothing will sell you on Gradle more than trying to work with Groovy and Maven together. There are two Maven plugins available for working with Groovy. One is the so-called "Groovy Eclipse" plugin, which actually has nothing to do with Eclipse, but assumes all your code (both Java and Groovy) is stored under src/main/java. The other is the GMaven project, which goes inactive for long periods of time. It generates Java stubs from all your Groovy files, and assumes that all your code (both Java and Groovy) is stored under src/main/groovy.

I might have those backwards. I'll have to look it up to be sure.

Either way, both Maven plugins put both code bases together. In Gradle I can customize it however I choose.

In one sense, though, mixing the code bases is a good thing. Oftentimes I'll have a Java class that depends on a Groovy class that depends on a Java class, and the cross-compiler makes that easy to handle.

My examples using both plugins are in the build chapter (chapter 5) of my GitHub repo.


Kenneth A. Kousen, Ph.D. (assorted certs), President, Kousen IT, Inc.
Author of Making Java Groovy - http://www.kousenit.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Making Java Groovy: Mevn description of mixed Java/groovy projects?