Changes in code are not recognised when debugging a multi-module

已回答

I have two modules which I put in the same project: Module 1 (Maven) has a dependency on module 2 (Gradle). The main class is in module 1 and it is uses classes from module 2.

As both are in the same project I can move without any problems from classes of module 1 to classes of module 2 and back. I can also set breakpoints in classes of module 2 and debug the whole code. But whenever I change the code in module 2 (and restart the debugger), the changes are not recognized and the debugger "skips" the new lines. I have tried to set the source in the module dependencies ("Project Structure"), rebuild the project, refresh dependencies - but nothing helps. The only why to make the debugger respect the changes in the code is to build module 2 and publish the jar to the local maven repo.

This is very annoying and time consuming. I have done this many times before with multiple maven modules (and older intellij versions). Is this a gradle problem? Is there any solution?

I am using intellij ultimate 2020.1

3

Hi. Could you please provide a demo project to reproduce a problem?

0

I have created a demo project. You can clone it from here: https://gerido@bitbucket.org/gerido/demo.git

Steps to reproduce:

  1. Build module2 and publish it to your local maven repo.
  2. Import both module to one project as shown in this screen-shot:
  3. Set a breakpoint somewhere in DemoClass#calculateSomething in module2.
  4. Start debugging from the main method in class MainDemo in module1.
  5. step through DemoClass#calculateSomething to make sure debugging is working properly.
  6. Stop debugging.
  7. Change the code in DemoClass#calculateSomething.
  8. Start debugging again.

Expected: the debugger steps through the changed code

Actually: the debugger ignores the changed code

0
Avatar
Permanently deleted user

We've had several engineers (4-7) run into same issue after upgrading to IntelliJ Ultimate 2020. Only fix was to uninstall IntelliJ Ultimate 2020, and revert back to 2019.

0

Thanks, but I don't think that downgrading to 2019 is a fix. Debugging is a core functionality of an IDE and it should work also in the new version.

0
Avatar
Permanently deleted user

I agree 100%, Ido. Sorry, I wasn't clear -- my info was intended for JetBrains Support. Unfortunately my comment was no help for you though. 

0

I know - my comment was also intended for JetBrains Support - they have a big problem with multi-module and gradle. I actually did downgraded to 2019 - it is impossible to work with 2020 if you use multi-module projects (which I do a lot). So thanks anyway for your comment and I really hope that JetBrains Support will answer soon.

0

Ido,
Unfortunately this scenario (mixed maven/gradle projects) is not supported at the moment, I have filed a task for it, please watch/vote here: https://youtrack.jetbrains.com/issue/IDEA-249639

0

PeteH,

Your case looks different. Please describe, what was working for you before the upgrade, and what is missing now?

0

Hi Nikita and thanks for answering.

First of all, the problem seems to be generally with gradle. I have changed the demo project so that both modules are now gradle modules, but the issue is still there. You can pull from the demo-repository and repeat the steps to reproduce from my earlier comment.

Before I mainly worked with maven, and multi-module project always worked for me without any issues. I am only working with gradle since a few month, and multi-module is very very annoying. I suspect that this issue is also existing in previous intellij versions - I downgraded to 2019.3.4, as recommended by PeteH, but this didn't help much.

 

0

Ido, for a pure-Gradle environment as a workaround, try using Gradle Composite build https://docs.gradle.org/current/userguide/composite_builds.html

You will have to link just one (composite) builds

 

0

Thanks Nikita, we will give it a try. In the meantime, in order to be able to work properly, we already combined some of our (separate) modules into a gradle multi-module. It would be very nice, though, if the multi-module functionality in intellij will work identically for maven and for gradle.

0

请先登录再写评论。