How to define Gradle's home in IDEA?

后端 未结 16 576
太阳男子
太阳男子 2020-12-04 04:37

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

16条回答
  •  -上瘾入骨i
    2020-12-04 05:26

    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}")
    }
    

提交回复
热议问题