Search code examples
javagitgradlegradlew

How can I configure the JDK for gradlew to use, on a per machine, per project basis?


The projects in question are from multiple open source organisations, with multiple rules on their gitignores / build.gradle / gradle wrappers.

My default system wide JDK is set to Open Java 11. I'd like to keep it to the latest, released JDK.

How can I override individual projects gradle wrappers to use a specific JDK?; without

  1. using command line arguments I won't be able to remember each time I need to invoke it.
  2. changing the projects existing gitignores, gradle wrappers, or committed buildscripts/properties.
  3. having changes needing to be ignored constantly in my local git repo.

Solution

  • http://www.jenv.be/ is a tool that is literally made to solve problems like this.

    What's jEnv ?

    jEnv is a command line tool to help you forget how to set the JAVA_HOME environment variable

    It can

    • List managed JDKs
    • Configure global version
    • Configure local version (per directory)
    • Configure shell instance version