Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ IDEA Gradle + Groovy

I am new to IDEA. What I would like to do is have a project (or module?) that has maven folder structure (aka src/main/java, src/main/groovy, src/test/groovy, etc), be managed by Gradle and support creation of Groovy classes, their compilation and execution.

What I tried:

  • Create a "Groovy" Project.
    • I can add "Maven" support, but not Gradle.
  • Create a "Gradle" project and add "Groovy" module to it
    • I can manage dependencies and plugins, but the file structure is screwed up.
      • The code goes into a sub-folder of the project (aka the name of the module)
      • I cannot directly add folders to the "src" of the module. When I copy them into the src folder they are considered package names.

What I am looking for:

  • Solution to the particular problem
  • General workflow for creating multi-facet (aka Gradle+Groovy or Java+Maven or Web+YouNameIt) project/modules.
  • Explanation of what is the reason for this paradigm/structure shift in IDEA?
like image 822
Daniil Shevelev Avatar asked Jan 27 '14 16:01

Daniil Shevelev


People also ask

Does IntelliJ IDEA come with Gradle?

Gradle The Gradle versions' support: starting with the version 3.0 and later. Note that for the Gradle version less than 4.8 and the Java version 11 there is an ongoing Gradle issue. If you work in IntelliJ IDEA, you don't need to install Gradle separately, IntelliJ IDEA does it for you.

Does IntelliJ support Groovy?

The Groovy plugin is bundled with IntelliJ IDEA and enabled by default. IntelliJ IDEA supports the latest stable version of Groovy and Groovy 4 syntax.

How do I enable Groovy in IntelliJ?

In the Project tool window, right-click the project and from the context menu, select Add Framework Support. In the dialog that opens, select Groovy and click OK. IntelliJ IDEA adds the Groovy SDK to your project and you can add Groovy classes and Groovy scripts.

Does Gradle include Groovy?

Dependency management Because Gradle's build language is based on Groovy, and parts of Gradle are implemented in Groovy, Gradle already ships with a Groovy library.


1 Answers

I would suggest not creating the project from inside Intellij.

Since Intellij imports Gradle projects quite nicely you can just import one of the pre-made Groovy Gradle Quick Starts you can find at the root of your Gradle installation.

For example $GRADLE_HOME/samples/groovy/mixedJavaAndGroovy has the exact Java/Groovy layout you describe with the HelloWorld Classes and Tests in place. Just copy it, rename the root folder, import it into Intellij and code!

like image 69
jeremyjjbrown Avatar answered Oct 02 '22 13:10

jeremyjjbrown