Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use IntelliJ to debug a Gradle Execute Task

I have the following Gradle task:

task execute(type:JavaExec, dependsOn:['build']) {
    main = 'com.something.Main'
    classpath = sourceSets.main.runtimeClasspath
}

When I debug the task in IntelliJ I get the following error:

ERROR: transport error 202: connect failed: Connection refused
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]
:execute FAILED
like image 322
Huj Avatar asked Nov 01 '22 10:11

Huj


1 Answers

It seems later versions of IntelliJ Idea cannot connect debuggers to forked test runners when using the Gradle Test runner.

In your sources root, add a gradle.properties file with the next two lines:

maxTestForks = 1
testForkEvery = 0

That should do the job.

like image 132
Mario Avatar answered Jan 04 '23 13:01

Mario