This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Is it possible in Maven (v3.0.3) to define a different compiler for code under src/test and for code under src/main? My motivation for wanting to do this is that I would like to start using the Spock framework for my developer testing, which requires Groovy, but do not want to use the Groovy compiler for the production code. At present I am unsure whether my company will allow production code to be compiled with anything other than javac.
So I'd like to tell Maven to use the Java compiler for src/main code and use the Groovy compiler for src/test code. Is this possible?
If you drop the groovy compiler plugin into your Pom, the groovy compiler plugin will compile groovy files, and maven compiler plugin will compile java files. All you need to do is make sure all your production code is in src/main/java and all your groovy test code is in src/test/groovy. Groovy compiler will compile files in src/test/groovy, and since it is a test folder the classes compiled by groovy won't go into production
Which groovy compiler plugin are you referring to? From what I can see of the documentation in order to include the Groovy compiler you have to reconfigure the maven-compiler-plugin plugin. This I imagine would then just replace the Java compiler completely causing all code to be compiled with the Groovy compiler.
How would I drop the Groovy compiler plugin into my pom as an additional compiler definition?
I had an interesting conversation with an old colleague of mine on this topic. He thinks that the Groovy compiler just converts the Groovy code into Java code which is then given to the Java compiler to be turned into bytecode as normal.