IntelliJ Gradle Support: Difference between revisions
Line 16: | Line 16: | ||
IDE determines the Gradle JVM according to the following algorithm, evaluating in order: | IDE determines the Gradle JVM according to the following algorithm, evaluating in order: | ||
* When the project is opened, check <code>gradle.properties</code> in the root of the project for <code>[[Gradle_System_Properties#org.gradle.java.home|org.gradle.java.home]]</code> system property and use the value if found. | * When the project is opened, check <code>gradle.properties</code> in the root of the project for <code>[[Gradle_System_Properties#org.gradle.java.home|org.gradle.java.home]]</code> system property and use the value if found. | ||
* Use the value specified in Gradle Settings → Gradle JVM. By default, that value is [[IntelliJ_Concepts#Project_SDK|Project SDK]]. | * Use the value specified in [[#Gradle_Settings_Gradle_JVM|Gradle Settings → Gradle JVM]]. By default, that value is [[IntelliJ_Concepts#Project_SDK|Project SDK]]. | ||
==Gradle Settings== | ==Gradle Settings== |
Revision as of 21:09, 30 June 2021
External
- https://www.jetbrains.com/help/idea/gradle.html
- https://www.jetbrains.com/help/idea/gradle-settings.html
Internal
Overview
Gradle is supported by IntelliJ via two plugins, which are installed and enabled by default: "Gradle" and "Gradle Extension". Gradle integration allows creating a Gradle project from the IDE, or opening an existing Gradle project with the IDE and managing it.
Concepts
Gradle JVM
IDE determines the Gradle JVM according to the following algorithm, evaluating in order:
- When the project is opened, check
gradle.properties
in the root of the project fororg.gradle.java.home
system property and use the value if found. - Use the value specified in Gradle Settings → Gradle JVM. By default, that value is Project SDK.
Gradle Settings
Gradle user home
Gradle JVM
See Gradle JVM above.
Operations
Create a New Gradle Project from the IDE
Open an Existing Gradle Project
Gradle Home
If asked to specify Gradle home, and get "Gradle location is incorrect", use the "libexec" subdirectory (/usr/local/Cellar/gradle/4.9/libexec).
IDEA Gradle Plugin
Configuring Gradle Sources
TODO: Gradle Operations | IDE Configuration
Importing a Project form a Gradle Model
Use auto-import - If selected, re-import of the project is done automatically every time you make changes to the project.
Group modules. See Grouping Modules.
SNAPSHOT Refresh Problem
There are cases when Gradle pulls the latest version of the SNAPSHOT and caches it in its dependency cache, but IntelliJ IDEA Gradle plugin does not seem to notice it and uses an old version of the snapshot. This is troublesome during debugging, when the source code as displayed by IntelliJ does not match the bytecode being debugged.
Possible solutions for this (have not tested any of them, do that next time when I need it):
1. Refresh Dependencies of the Gradle Module
Gradle tab -> Select the module -> Right click -> Refresh Dependencies
2. Remove the Problem Dependency
Project Tab -> External Libraries -> expand Gradle: library-name -> Select "library root" -> Delete.
Then go to the Gradle tab and refresh dependencies.