Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any reason to use javac over groovyc in a mixed code project?

In setting up a mixed java7/groovy2 project in maven or gradle, is there any reason for compiling first with javac then groovyc over just letting groovyc handle it all?

I started out compiling them separately and in their own trees (src/main/java and src/main/groovy) as best-practice suggests. However, since java and groovy are used to solve the same problem and are so intermingled, I am now leaning towards dumping all my source into src/main/groovy and letting the groovy compiler handle both .java and .groovy files. This seems to make the project easier to follow when looking at the source tree. Are there any disadvantages?

like image 597
Daniel Bower Avatar asked Feb 05 '13 15:02

Daniel Bower


1 Answers

Letting groovyc handle both .java and .groovy is good. This approach is also used by the Grails framework. Grails 2 puts all .java files under groovy source directories, like you did. What you're doing now is the best-practice.

Here's an example: https://github.com/groovy/groovy-core/tree/master/src/main/groovy/io

like image 139
chanwit Avatar answered Nov 07 '22 01:11

chanwit