I am trying to import a Gradle project into IntelliJ, and when I get to the Gradle Home
textbox, it is not automatically populated, nor will typing in the path
I had some weird errors where it could not find my class, I had to right click on my src folder (was red) to "Make Directory as" -> Source Folder Root
In case you are using Mac, most probably your gradle home should be /usr/local/gradle-2.0
for example.
In preference of IDEA search for gradle and set gradle home as given above. It should work
Installed on a Mac via Homebrew, the path
/usr/local/opt/gradle/libexec
is preferable to
/usr/local/Cellar/gradle/X.X/libexec
since the former will survive version upgrades.
If you are using IntelliJ, just do the following.
That's all.
This is instruction for MAC only.
I had the same problem. I solved it by configuring $GRADLE_HOME
in .bash_profile
. Here's how you do it:
.bash_profile
(usually it's located in the user’s home directory).$PATH
variable:
export GRADLE_HOME=/usr/local/opt/gradle/libexec
export PATH=$GRADLE_HOME/bin:$PATH
source .bash_profile
I wrote my own article with instruction in a case if somebody will encounter the same problem.
You can write a simple gradle script to print your GRADLE_HOME
directory.
task getHomeDir {
doLast {
println gradle.gradleHomeDir
}
}
and name it build.gradle
.
Then run it with:
gradle getHomeDir
If you installed with homebrew, use brew info gradle
to find the base path (i.e. /usr/local/Cellar/gradle/1.10/
), and just append libexec
.
The same task in Kotlin in case you use build.gradle.kts
:
tasks.register("getHomeDir") {
println("Gradle home dir: ${gradle.gradleHomeDir}")
}