Debugging gradle tasks in IntelliJ

I am trying to start a task in debug mode and stop it at breakpoints, but it does not work. The task runs fine, but the IDE gives me a socket error:

Error starting MyProject [myTask]: Unable to open the debugger port (127.0.0.1ל2550): java.net.SocketException

Note that the port tries to use the changes every time it tries. I was thinking of adding something to VM Options: in the task configuration, but I have no idea what.

+5
source share
2 answers

I had a similar problem, but I couldn’t even build using gradle, since that would give me "Unable to open the debugger port (127.0.0.1:xxxxx):" when it hit a specific subproject

What I found was a special character used in char char degreeSymbol = '°'; which caused the failure, and why it could not open the debugger port.

In the verification folder there is a gradle task called "test" that will find this problem and show you exactly where.

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

To fix the problem, either change the special character to unicode final String DEGREE = "\u00b0"; or in the root directory of Gradle.build do:

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

or if you have several subprojects:

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

Create a new launch configuration. Select "Application" as the configuration type (i.e. Not "Gradle"). Then select the main class to run. IntelliJ first starts gradle, as usual, and runs the selected class in debug mode. I am not sure if there are any restrictions since I myself found this solution.

0
source

Source: https://habr.com/ru/post/1238129/


All Articles