# How to debug custom plugin?

**URL:** <https://discuss.gradle.org/t/how-to-debug-custom-plugin/24969>\
**Category:** Help/Discuss\
**Tags:** buildship, plugins\
**Created:** [December 1, 2017, 8:07am UTC](https://discuss.gradle.org/t/how-to-debug-custom-plugin/24969 "2017-12-01T08:07:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanchezwangNanjing](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@sanchezwangNanjing](https://discuss.gradle.org/u/sanchezwangNanjing)\
**Post date:** [December 1, 2017, 8:07am UTC](https://discuss.gradle.org/t/how-to-debug-custom-plugin/24969/1 "2017-12-01T08:07:17Z")

</div>

Hi All expert,

I have own developed plugins. At the moment, i build it and upload them to maven. Then run build for the project which use this plugin to see the result. This is not efficient way to test.  
Is there any way to debug the custom plugin directly from main project?  
I saw some blogs which set org.gradle.debug=true. But it seems it does not help in my case.  
Thanks for your help in advance.

---

<div class="post-metadata">

**Author:** ![Stefan\_Wolf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/stefan_wolf/32/5519_2.png) [@Stefan\_Wolf](https://discuss.gradle.org/u/Stefan_Wolf)\
**Post date:** [December 1, 2017, 8:31am UTC](https://discuss.gradle.org/t/how-to-debug-custom-plugin/24969/2 "2017-12-01T08:31:57Z")

</div>

I guess what you are looking for is [composite builds](https://docs.gradle.org/current/userguide/composite_builds.html).  
Using composite builds, you can include your plugin build and directly use it in your project without publishing the plugin to a Maven repository. The [blog post](https://blog.gradle.org/introducing-composite-builds) contains an example how to do so.

---

<div class="post-metadata">

**Author:** ![sanchezwangNanjing](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@sanchezwangNanjing](https://discuss.gradle.org/u/sanchezwangNanjing)\
**Post date:** [December 1, 2017, 9:05am UTC](https://discuss.gradle.org/t/how-to-debug-custom-plugin/24969/3 "2017-12-01T09:05:31Z")

</div>

Hi Stefan,

I am not taking about composite build. I am talking about how to debug own developed plugin.  
I have an own developed plugin which do special steps with groovy code.Then I used apply plugin ‘plugin name’ in build.gradle.

Now I want to debug the plugin to see my own code works properly or not.

---

<div class="post-metadata">

**Author:** ![Stefan\_Wolf](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/stefan_wolf/32/5519_2.png) [@Stefan\_Wolf](https://discuss.gradle.org/u/Stefan_Wolf)\
**Post date:** [December 1, 2017, 9:18am UTC](https://discuss.gradle.org/t/how-to-debug-custom-plugin/24969/4 "2017-12-01T09:18:42Z")

</div>

If you want to debug a build, run the build with `-Dorg.gradle.debug=true`, as you said above. Then you need to set the appropriate breakpoints and should be good to go. Using a composite with this flag has the advantage that you can directly navigate to the sources of your plugin.  
You may be interested in this Webinar: [https://blog.jetbrains.com/idea/2017/03/webinar-recording-composite-builds-with-gradle/](https://blog.jetbrains.com/idea/2017/03/webinar-recording-composite-builds-with-gradle/)

---

<div class="post-metadata">

**Author:** ![edsonschleiwabion](https://avatars.discourse-cdn.com/v4/letter/e/bc8723/32.png) [@edsonschleiwabion](https://discuss.gradle.org/u/edsonschleiwabion)\
**Post date:** [December 7, 2017, 8:03am UTC](https://discuss.gradle.org/t/how-to-debug-custom-plugin/24969/5 "2017-12-07T08:03:25Z")

</div>

Hi @sanchezwangNanjing,

Look how others developers test/implement the gradle plugins, an example of how to test a plugin without deploy:

> <https://github.com/palantir/gradle-git-version/blob/develop/src/test/groovy/com/palantir/gradle/gitversion/GitVersionPluginTests.groovy>
