Debugging Gradle source code in IntelliJ

Posted by Dan Siwiec on December 21, 2014 gradle intellij debugging

If you find yourself needing to debug Gradle source code, here’s a few simple steps you need to follow. There are some great posts online that explain how to attach a remote debugger, like this one.

In this post I show an alternative solution which runs Gradle inside the IDE.

  • Clone Gradle repository:
git clone git@github.com:gradle/gradle.git
  • Checkout a specific release:
git tag -l
git checkout tags/REL_2.2.1
  • Generate IntelliJ files:
cd gradle
./gradlew idea
  • Import Gradle project into IntelliJ:

  • Edit Gradle Run Configuration to point to the project you want to run gradle on:

The -b option allows you to pass a path to the build.gradle

  • Set your breakpoints

  • Hit Debug and wait for your breakpoint: