With a suitable configuration, you can have bidirectional dependencies between Java and Groovy, and/or Java and Scala. You can have unidirectional dependencies between Groovy and Scala (either Groovy->Scala or Scala->Groovy).
Interesting. Is there an example project I can look at? I would much appreciate it!
I have been able to get bidirectional between Java and Groovy. But to have that together with bidirectional Java and Scala. That would be great. To have Scala work with Groovy would be awesome!!! Please advice!
Thinking about this again, I don’t see a way to get bidirectional Java/Groovy and Java/Scala. At the very least, you’d have to partition your Java code into one part that only interacts with Groovy code, and another one that only interacts with Scala code.
Thank you Darek! I would definitely take a look at it. Unfortunately, going back to Maven is not a choice at work. Besides Gradle does simplify things a lot. I am just hoping that if Maven can do it then hopefully we can find a way to do so in Gradle too! Else Gradle can become an impediment towards polyglot involving more than 2 languages!
You could do something similar by calling Ant from Gradle like Darek’s Maven build does. Groovy’s stub generator isn’t exposed as a standalone task in Gradle, because it’s known to be flawed and unfixable. For Groovy 2.4, stubless joint generation (which Scala has been doing for a long time) has been promised, which can be totally reliable, but doesn’t allow for Darek’s solution.
The only reliable solution for Java-Groovy-Scala joint compilation that I’m aware of involves enhancing the Groovy joint compiler to be able to parse the Scala language, or the Scala joint compiler to be able to parse the Groovy language. I haven’t heard of anyone working on that.
Exactly as Peter said. My solution will not work in all cases. Only joint compiler parsing all 3 languages at the same time would be the definitive solution. But I don.t feel like writing one
Maybe some day, some one will come up with pluggable joint compiler for JVM? So that you would be able to plug in any JVM compiler to work side by side any other? But that seems like a long shot. And would it be really useful? Do you see a good use case to even have those 3 languages in one module?