How to debug a project in Intellij while setting the breakpoints in another project
intellij debugger not working
how to stop debugging in intellij
intellij breakpoint not working
intellij view breakpoints
intellij debug shortcuts
debug button disabled in intellij
intellij debug step back
I have a (Maven-based) project A loaded in Intellij that has a number of dependencies.
I have the source files of one of those dependencies (say B) in another Intellij project.
I would like to put breakpoints in B and debug project A so that A stops when breakpoints are reached in project B.
In Eclipse, I just need to have both projects in the same workspace and it works. Since there are no workspaces in Intellij, I wonder how to do it, and if it is possible.
When working with multiple maven projects, I find it convenient to put both under a parent maven project. The two child projects are not aware of the parent and remain independent of each other, but by aggregating them on one parent pom, you can conveniently build and test them at the same time, keeping the dependent in sync with its dependency. When you do that, you can also create Run configurations for each project, launch them in debug mode, and put breakpoints in either or both of them.
The parent pom stays in the parent folder of both projects, and does not need to go into source control because the child poms don't refer to it as their parent--its only for your convenience in working on both at the same time. Such a pom might look like:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>anything</groupId> <artifactId>anything</artifactId> <version>0.0-SNAPSHOT</version> <packaging>pom</packaging> <name>All projects</name> <modules> <module>project-1-subdirectory</module> <module>project-2-subdirectory</module> </modules> </project>
Breakpoints - Help, How to configure the debugger settings. on the installed/enabled plugins, you can also debug code written in other languages. During a debugging session, you launch your program with the debugger attached assumes that you are building and running your project from IntelliJ IDEA. This is done using breakpoints. Line breakpoints. Line breakpoints can be set on executable lines of code. Thread execution is suspended before the line with such breakpoint, and IntelliJ IDEA displays the stack frames on that thread's stack. Place the caret at an executable line of code where you want to set a breakpoint.
Debug code - Help, The debugger is attached behind the scenes, so you don't have to configure anything While IntelliJ IDEA provides a way to debug simple applications without any Pausing the program manually is not an alternative to using breakpoints as this external tools or performing other actions before every debugging session. I am trying to debug a unit test in a Maven project. Normally I would just set up a JUnit test configuration in Intellj and set a breakpoint on the line I'm interested in. Unfortunately this particular bug only shows when a certain Maven profile is used.
The other answers sound like they would work, but all I had to do was go to:
Project Structure (Alt+Shift+S)
> on the Sources tab for the module that has dependencies, look on the right side,
click the + Add Content Root, then add the
src folder of the dependency project.
I was able to then put breakpoints in those
src files and IntelliJ would step to them in debugging.
(Note you may see the warning "
Alternative source available for the class ...")
"Modules normally have one content root. You can add more content roots. For example, this might be useful if pieces of your code are stored in different locations on your computer."
Start the debugger session - Help, While debugging an application, you typically follow the normal flow of a program. you can use non-suspending breakpoints that evaluate an expression when hit. project before reloading classes option is enabled in Settings/Preferences 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'
Alter the program's execution flow - Help, Introduction · Installation guide · Getting started · IDE configuration · Project The Attach to process feature allows you to debug a project which you are developing debugging the same way as you usually do it in IntelliJ IDEA (set breakpoints, When finished, detach the process: select the Run | Stop or click the Stop the Force break at the first line when the script is outside the project: Select this checkbox to have the debugger stop at the first line as soon as it reaches and opens a file outside the current project. With this checkbox cleared, the debugger continues upon opening a file outside the current project.
Attach to process - Help, File | Settings | Build, Execution, Deployment | Debugger for Windows and Linux If this checkbox is selected, on hitting a breakpoint, IntelliJ IDEA will show the Automatically hide the Debug tool window when the debugged program The alternative source switcher appears on top of the editor, if in project there is more Debug configuration (or debug context if you prefer) is an extention of a run configuration and allows you to define a local set of breakpoints, watches etc. All elements of the configuration (i.e. breakpoints for example) can be configured to be local to configuration, shared across all configurations (global) or shared between certan
- That's cheating with Intellij, but it does the job!
- I don't think this is cheating, it's the way maven works. I'm super happy I found this post, as my only problem with IntelliJ (coming from NetBeans) so far was that I was unable to open multiple projects simultaneously. This restores that functionality. I am in love!
- I think having projects A and B as modules of the same parent project as suggested by @Hank D is a bit of a hack because it diverts from the original purpose of multi-module maven projects. Besides, what if A or B already has a parent project? I added another answer that is generic and works with maven and gradle projects.