Gradle Project - I can set breakpoint, but it's never hit.

已回答

IDEA newbie here.    

I can create a Java project, run debug, and hit a breakpoint with no problems.  

However, I'm unable to do the same with a Gradle project using IntelliJ 2016.2.3.  

I see it start the process and attach, so in theory, it should work.   Or, that's how I interpret this line:

Connected to the target VM, address: '127.0.0.1:60233', transport: 'socket'

I've tried with both JDK 1.7 and 1.8.  Gradle 3.2.1.   

When I google, I get many hits for being unable to set a break point.   It appears to set just fine: 

However, it prints out the project base, but the break point is not caught.  The gradle project has a RunExec task that runs fine; however, it's the same problem in the application.   I'm unable to debug it. 

Any ideas?    I'm stuck. 

 

 

0

What run/debug configuration type do you use?

Do you try to debug the Gradle build script itself or a Groovy script?

If there is no checkmark on the breakpoint, it means there is no executable code found in the JVM that IntelliJ IDEA has connected to.

Note that with Gradle projects some configurations will spawn new JVM instances and you may be connecting to the wrong instance where there is no your code running.

0

Thanks for the response.    My test code is just a plain jane Java App, and when I run it as a Java application, the breakpoint works and it shows up as a check: 

However, that check disappears the application completes.    It makes me think that this is something specific to the gradle integration in IntelliJ. 

 

 

0

You're a genius.   I was investigating the daemon task and figured out that there were two running.   IntelliJ must be getting confused over which daemon it owns.   I think it's a bug as it should know the port that the daemon is coming up on. However, I have a work around.  

Thanks for the help!

btw, Is there a way to debug the gradle scripts?   It's just groovy code, so it seems possible.   

 

0

I'm just starting to use Intellij ultimate and not being able to just debug using an IDE is a real PITA! I still haven't got it working and googled quite some hours to figure it out. A lot of results and might work for advanced Intellij users.

For me, as a beginner, it is not clear at all that only breakpoints with a check sign will be hit. If I set breakpoints and they don' t give a warning or error, I expect them to work. So from usability perspective it should be the other way around. Without check means fine, and they should add some warning sign when they are not. As a user beginning Intellij, it feels like the IDE is simply broken/not working. And in some way I believe it is because a process I start with the IDE in debug mode (SHIFT-F9) should actually be debuggable. It should at least give feedback to the user if this is not possible for some reason. 

After years of development in other languages I switched back to Java got Intellij Ultimate because it be the best choice of IDE. I think for the most part it is a great IDE with some excellent features. But  I am really getting wary of Intellij because it seems like basic features I'm used to in other IDE's, like active monitoring of errors and warnings, hovering tooltips in code view (for example, getting method info when hovering the mouse above a method call), and now lost a complete morning figuring out how to start a gradle project in debug mode (still without any success I might add). I tried remote debug but, aside from feeling as some kind of last resort solution, I can't get it to work (also, I checked to make sure I have no gradle deamon running).

To be honest I'm quite disappointed because integrated debugging is a main feature an IDE should provide. The lack of feedback (checked breakpoints and "run in debug" while it isn't) leaves me in the dark and frustrated. When saying "with Gradle projects some configurations will spawn new JVM instances and you may be connecting to the wrong instance" the problem is shifted to me and only adds to my frustration. But when starting in debug mode I expect the tooling to compile, assemble, link, start and figure out which process it just started and to debug that instance. Only when I want to debug a process the IDE did not start I feel responsible for connecting to it. 

I really hope these issues will be addressed. And if it isn't for me then for future newcomers to Intellij.

0

Please submit a ticket to support at https://intellij-support.jetbrains.com/hc/ and provide a sample project that you can't debug so that we can understand what is the problem.

0
Avatar
Permanently deleted user

While I'm not the OP, I'm running into the same issue and I've created an issue here:

https://youtrack.jetbrains.com/issue/IDEA-236833

 

A sample project that reproduces the error is attached.  Good luck!

0

请先登录再写评论。