Building mixed Groovy & Java applications

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

Building mixed Groovy & Java applications

Marcus Ilgner
Hi all,

I have a Griffon-based application that contains both Java and Groovy code. From within IntelliJ IDEA, I can build and launch the app just fine. However, when trying to build from the command line, the Java code always complains that it cannot find the groovy classes. The "groovy" plugin in Gradle is active and there is a dependency on groovy, too.

As I am working in IDEA most of the time, this would not be a major problem - except that I don't know how to create a distribution from within IDEA :D
Any idea how to get this to work? Or - alternatively - how to create a distributable JAR from within IDEA?

All the best
Reply | Threaded
Open this post in threaded view

Re: Building mixed Groovy & Java applications

Hi Marcus,

You can call any Gradle task form within IntelliJ. Typical distribution tasks include

  - Fat JAR: gradle shadowJar
  - ZIP file: gradle distZip

I'm puzzled by the fact that Idea can find both Groovy & Java classes but the command line doesn't.
By any change is the following line in your build file?

   compileGroovy.enabled = false

If so then please remove it, this stops Gradle from compiling Groovy classes.
Also, it may be a good idea to move all Java sources to src/main/groovy as the Groovy joint compiler will kick in, making sure Java source can reach Groovy classes.