Skip to content

Instantly share code, notes, and snippets.

@sterlingwes
Last active January 20, 2021 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sterlingwes/4f7373fba213e76d1e2b5ed7aeafbdc6 to your computer and use it in GitHub Desktop.
Save sterlingwes/4f7373fba213e76d1e2b5ed7aeafbdc6 to your computer and use it in GitHub Desktop.
Debugging a third party gradle plugin

A third party Gradle plugin can be difficult to debug. In my case, I couldn't figure out why an input in my build.gradle file wasn't causing the plugin to add a desired task to a build. It's also not straightforward to inspect the source code of a plugin that arrives prebuilt. Fortunately if the plugin is open source, you can breakpoint in the source.

This thread forms the basis of these steps:

  • clone the source code for the plugin, and checkout the commit or version tag reflecting the version of the plugin you want to debug
  • open the repo in IntelliJ IDEA / Android Studio and allow gradle to sync
  • create a run configuration, selecting Attach to Remote JVM
  • make your breakpoints in the source code
  • in the project with the gradle build you want to debug, run ./gradlew --no-daemon -Dorg.gradle.debug=true app:uploadBugsnagReleaseSourceMaps, gradle will wait for a debugger to attach
  • back in the source code repo for the plugin, hit Debug
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment