Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debug gradle task in IntelliJ

I'm trying to run a task in debug mode and have it stop in breakpoints but it doesn't seem to work. The task executes normally but the IDE gives me a socket error:

Error running MyProject [myTask]: Unable to open debugger port (127.0.0.1:52550): java.net.SocketException

Note that the port it tries to use changes on every try. I thought of adding something to VM Options: in the task configuration but I have no idea what.

like image 494
PentaKon Avatar asked Oct 31 '22 13:10

PentaKon


1 Answers

I had a similar issue to this, but I could not even build with gradle as it would give me "Unable to open debugger port (127.0.0.1:xxxxx):" when it got to a certain sub-project

What I found was a special character used in a char char degreeSymbol = '°'; that was causing something to crash and that's why it was unable to open the debugger port.

There is a gradle task called "test" under the verification folder that will find this issue and show you exactly where it is.

In IntelliJ community edition 2016.2 you can find this by going to View > Tool Windows > Gradle. Then expand the name of your project (root) > tasks > verification.

To fix the issue either change the special character to a unicode string final String DEGREE = "\u00b0"; or in your root gradle.build do:

apply plugin: 'java'
compileJava { options.encoding = "UTF-8" }

or if you have multiple sub-projects:

allprojects {
    apply plugin: 'java'
    compileJava { options.encoding = "UTF-8" }
}
like image 134
willbush Avatar answered Dec 19 '22 22:12

willbush