# Problem debugging build with eclipse remote debugger

**URL:** <https://discuss.gradle.org/t/problem-debugging-build-with-eclipse-remote-debugger/7045>\
**Category:** Old Forum Archive\
**Created:** [December 5, 2012, 11:31am UTC](https://discuss.gradle.org/t/problem-debugging-build-with-eclipse-remote-debugger/7045 "2012-12-05T11:31:00Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![u1234](https://avatars.discourse-cdn.com/v4/letter/u/2acd7d/32.png) [@u1234](https://discuss.gradle.org/u/u1234)\
**Post date:** [December 5, 2012, 11:31am UTC](https://discuss.gradle.org/t/problem-debugging-build-with-eclipse-remote-debugger/7045/1 "2012-12-05T11:31:00Z")

</div>

I am trying to debug a gradle build. In cmd I type:

```gradle
set GRADLE_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

```

next I build the project:

```gradle
gradle build

```

But instead of waiting for me to launch the remote debugging inside eclipse the build terminates:

```gradle
C:\workspac\test>gradle build
  Listening for transport dt_socket at address: 8000
  INFO: Added configuration: provided
  ...
  ...
  BUILD SUCCESSFUL
    Total time: 9.881 secs

```

Why does the gradle build not wait for me to connect with the remote debug process from eclipse?

---

<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:** [December 5, 2012, 4:16pm UTC](https://discuss.gradle.org/t/problem-debugging-build-with-eclipse-remote-debugger/7045/2 "2012-12-05T16:16:00Z")

</div>

Because you set ‘suspend=n’.

---

<div class="post-metadata">

**Author:** ![u1234](https://avatars.discourse-cdn.com/v4/letter/u/2acd7d/32.png) [@u1234](https://discuss.gradle.org/u/u1234)\
**Post date:** [December 5, 2012, 6:59pm UTC](https://discuss.gradle.org/t/problem-debugging-build-with-eclipse-remote-debugger/7045/3 "2012-12-05T18:59:00Z")

</div>

Ah yes changing to suspend=y makes it wait, thanks!

I then set a breakpoint in my build.gradle file in a task that I am running from commandline. But it never stops at the breakpoint when I launch the remote debug process from eclipse (socket Attach on port 5005).

Do I need to run the build with some special parameter?

---

<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:** [December 5, 2012, 7:12pm UTC](https://discuss.gradle.org/t/problem-debugging-build-with-eclipse-remote-debugger/7045/4 "2012-12-05T19:12:00Z")

</div>

Without special tooling support, you won’t be able to step through build scripts in the debugger. And from what I know, the Eclipse Gradle tooling doesn’t currently provide such support. You should be able to debug custom task classes and plugin classes though, as long as you make them known to the IDE.

---

<div class="post-metadata">

**Author:** ![u1234](https://avatars.discourse-cdn.com/v4/letter/u/2acd7d/32.png) [@u1234](https://discuss.gradle.org/u/u1234)\
**Post date:** [December 5, 2012, 7:28pm UTC](https://discuss.gradle.org/t/problem-debugging-build-with-eclipse-remote-debugger/7045/5 "2012-12-05T19:28:00Z")

</div>

Ok I can now debug a plugin I have written and applied in my script. In my script I also call a java class:

```gradle
afterEvaluate{
        project.javaexec {
          main = com.MyMain
          ...

```

Even though I set a breakpoint in MyMain it does not stop in the class. Is this expected behavior too?

---

<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:** [December 5, 2012, 7:33pm UTC](https://discuss.gradle.org/t/problem-debugging-build-with-eclipse-remote-debugger/7045/6 "2012-12-05T19:33:00Z")

</div>

‘project.javaexec’ creates a new process, so you’ll have to debug that process (and set the usual debug JVM args for it). To simplify this, you can do ‘javaexec { debug = true }’. For more information, see the DSL reference for ‘JavaExec’.

---

<div class="post-metadata">

**Author:** ![u1234](https://avatars.discourse-cdn.com/v4/letter/u/2acd7d/32.png) [@u1234](https://discuss.gradle.org/u/u1234)\
**Post date:** [December 5, 2012, 8:33pm UTC](https://discuss.gradle.org/t/problem-debugging-build-with-eclipse-remote-debugger/7045/7 "2012-12-05T20:33:00Z")

</div>

Thanks I can now debug my executed java code 🙂

---

<div class="post-metadata">

**Author:** ![Thag](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/thag/32/357_2.png) [@Thag](https://discuss.gradle.org/u/Thag)\
**Post date:** [September 9, 2013, 5:11pm UTC](https://discuss.gradle.org/t/problem-debugging-build-with-eclipse-remote-debugger/7045/8 "2013-09-09T17:11:00Z")

</div>

Should I be able to set breakpoints in an inline groovy method that’s embedded in my gradle script?

eg:

```gradle
task info << {
 logger.lifecycle('info')
 sendNotification(new URL(jobUrl), 'RUNNING')
...
  void sendNotification(URL jobUrl, String status) {
 logger.lifecycle("sendNotification: ${jobUrl} = ${status}") <- break here?
 try {
  HttpURLConnection httpCon = (HttpURLConnection) jobUrl.openConnection()
  httpCon.setDoOutput(true)
  httpCon.setRequestMethod("PUT")
...

```

I am doing something wrong as that’s not working. The debugger connects and runs to completion without breaking.
