Recommended plugin debugging technique

I have problems with a Gradle build - an external plugin is not working with my configuration (input data and settings in build.gradle) and/or my environment (OS). Since the plugin source is available on Github I want to debug the reason and help the plugin autor to identify or even fix the issue.

So my project (I will call it ‘client’) has all the input data and configuration and the plugin source (I will call it ‘plugin’) comes with the code of the plugin. Ideally I wouldn’t have to change the plugin not for integrating client and plugin.

So how do I make the setup for debugging?

  1. Is it possible to debug in my client project or 2) do I have to build a new test project with the tooling api?

Ad 1) In the samples I saw that I have to change the plugin build.gradle to upload the JAR into a local directory (…\repository) and change the repository also in the client build configuration. Is there a better solution like setting up a multi module project (do I have to change the directory layout of my existing client project) or referencing the plugin jar directly?

Ad 2) When using the tooling api do I have to duplicate client data and client configuration for performing the test?

How do I set breakpoints within the plugin task?

I looked at the tooling api and plugin samples, however I saw unit test for plugin testing, but never a concrete scenario test. Would be great if someone could point me in the right direction.

Kind regards, CL

To debug a plugin, run the build with ‘–no-daemon -Dorg.gradle.debug=true’ and connect an external debugger that has access to the plugin sources on port 5005.

1 Like

Thanks, that worked. So to summarize I did the following:

  1. Opened the plugin in IDEA and defined a remote debug configuration 2) Opened the console in the clients directory 3) set the environment var GRADLE_OPTS to -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005 4) Started gradle for the client 5) Started Idea debug

Thanks a lot for your help

Instead of setting ‘GRADLE_OPTS’, t’s easier to pass ‘-Dorg.gradle.debug=true’ when calling Gradle.

I was not precise in my answer: 4) Started gradle for the client with gradlew --no-daemon -Dorg.gradle.debug=true

But it is strange that I needed GRADLEOPS AND -Dorg.gradle.debug?=true to get IDEA synced with gradlew.

That’s strange, always worked for me. And if you set ‘GRADLE_OPTS’, you definitely shouldn’t need ‘-Dorg.gradle.debug’.

The answer is correct. Just be aware that underscores disappeared from original Christian post. Variable is

GRADLE\_OPTS

Value of environment variable is

-Xdebug -Xrunjdwp:transport=dt\_socket,server=y,suspend=y,address=5005