# Recommended plugin debugging technique

**URL:** <https://discuss.gradle.org/t/recommended-plugin-debugging-technique/6880>\
**Category:** Old Forum Archive\
**Created:** [October 18, 2013, 12:17pm UTC](https://discuss.gradle.org/t/recommended-plugin-debugging-technique/6880 "2013-10-18T12:17:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christian\_Lipp](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Christian\_Lipp](https://discuss.gradle.org/u/Christian_Lipp)\
**Post date:** [October 18, 2013, 12:17pm UTC](https://discuss.gradle.org/t/recommended-plugin-debugging-technique/6880/1 "2013-10-18T12:17:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [October 18, 2013, 7:39pm UTC](https://discuss.gradle.org/t/recommended-plugin-debugging-technique/6880/2 "2013-10-18T19:39:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Christian\_Lipp](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Christian\_Lipp](https://discuss.gradle.org/u/Christian_Lipp)\
**Post date:** [October 23, 2013, 9:25am UTC](https://discuss.gradle.org/t/recommended-plugin-debugging-technique/6880/3 "2013-10-23T09:25:00Z")

</div>

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

1. Opened the plugin in IDEA and defined a [remote debug configuration](http://www.jetbrains.com/idea/webhelp/run-debug-configuration-remote.html) 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

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [October 23, 2013, 10:13am UTC](https://discuss.gradle.org/t/recommended-plugin-debugging-technique/6880/4 "2013-10-23T10:13:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Christian\_Lipp](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Christian\_Lipp](https://discuss.gradle.org/u/Christian_Lipp)\
**Post date:** [October 23, 2013, 12:25pm UTC](https://discuss.gradle.org/t/recommended-plugin-debugging-technique/6880/5 "2013-10-23T12:25:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)\
**Post date:** [October 23, 2013, 12:34pm UTC](https://discuss.gradle.org/t/recommended-plugin-debugging-technique/6880/6 "2013-10-23T12:34:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![georgik](https://avatars.discourse-cdn.com/v4/letter/g/e47774/32.png) [@georgik](https://discuss.gradle.org/u/georgik)\
**Post date:** [June 23, 2014, 8:16pm UTC](https://discuss.gradle.org/t/recommended-plugin-debugging-technique/6880/7 "2014-06-23T20:16:00Z")

</div>

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

```gradle
GRADLE\_OPTS

```

Value of environment variable is

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

```
