Intellij IDEA debugger not working on Vert.X Gradle project

I am developing a project using the Vert.X using the Gradle build tool. My problem is that breakpoints in IntelliJ just don't work as I tried.

Here is the startup configuration for Vert.X that I use in Gradle:

 run { args = [ 'run', mainVerticleName, "-conf", confPath, "--redeploy=$project.ext.watchForChange", "--launcher-class=$mainClassName", "--on-redeploy=$project.ext.doOnChange" ] } 

So, deployment is done using Gradle , performed without any problems, IntelliJ debugger is connected, but breakpoints do not work .

How I tried to make it work:

1) Gradle to complete the configuration. Here is the launch configuration for Intellij IDEA : Intellij Run Configuration with Gradle

I tried using the Remote Debugging tool, launched the application with the following VM parameters:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000

But that did not work.

2) Application configuration: IntelliJ Run Configuration using Application

In this case, I just can not start the project, because when I start, I get the following message:

Error: Could not find or load main class io.vertx.core.Launcher

Vert.X Core library is on its way to classes, and the configuration seems to be correct, so it can't be a problem.

The source code of the project is publicly available and can be found on GitHub :

vertx- gradle -architecture-starter

The version of Vert.X is 3.4.0. Gradle version is 3.4.1. IntelliJ IDEA Version 2016.3.5. OS - MacOS Sierra 10.12.3.

An interesting fact is that I deploy Vert.X from tests - breakpoints work. Any ideas why breakpoints don't work in the cases described above?

+5
source share
2 answers

Here are solutions to both problems. Thanks @CrazyCoder for helping with this.

1) run is executed in a separate virtual machine. Therefore, to make it work, I added the --java-opts to the script:

 run { args = [ 'run', mainVerticleName, "-conf", confPath, "--redeploy=$project.ext.watchForChange", "--launcher-class=$mainClassName", "--on-redeploy=$project.ext.doOnChange", // used for attaching remote debugger "--java-opts", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000" ] } 

This allows you to connect the Remote debug configuration on port 8000 .

2) By default, Intellij IDEA creates separate modules for each set of sources, so I had the source sets for the api_main and api_test . After disabling this feature, the application debugging started.

This can be disabled in the Gradle settings. Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle : uncheck the box to create separate modules for each set.

enter image description here

This is the Intellij IDEA problem - link .

+5
source

I had the same problem and worked after me. redistribution, launch, and redeploy options are not required in intelliJ. if we remove that debugging work after the application.

 run { args = [ 'run', mainVerticleName, "-conf", confPath ] } 
+1
source

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


All Articles