How to debug custom plugin?

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/