2

I want to debug into code generated by Dagger in IntelliJ. The source files generated by Dagger are put into /target/generated-test-sources/test-annotations and /target/generated-sources/annotations.

I've looked at the Run/Debug Configurations dialog, and didn't see anything obvious. I've also checked the Module Settings and both of these are listed as Source Folders so IntelliJ definitely knows they're source, but for some reason won't hit on any breakpoints I put in generated code.

3 Answers 3

2

For IntelliJ 13.1.5:

If /target/generated-sources/annotations is marked as a generated source root, IntelliJ never triggers breakpoints. If /target/generated-sources/annotations isn't marked as generated source root, IntelliJ will trigger the breakpoints, but it won't jump to the associated source.

  1. Unmark /target/generated-sources/annotations as a generated sources root
  2. Set your breakpoints in the generated source
  3. Run your code to trigger the breakpoint
  4. Mark /target/generated-sources/annotations as a generated sources root

IntelliJ now behaves as expected. You'll probably need to remove /target/generated-sources/annotations after you're done for breakpoints to be triggered again.

I've created an IntelliJ bug for this issue. Please upvote it.

Sign up to request clarification or add additional context in comments.

Comments

0

All you need is the source files somewhere available to IDEA, then you should be able to debug. Make sure the folders containing the files is included in the project structure settings, then you should be able to open the files with ctrl+n and set breakpoints.

2 Comments

They are listed as source folders in module settings already.
Can you open them? Perhaps you need to mark the folders they are in as source root. This can be done by right-clicking the folder and selecting "Mark as". Are the breakpoints indicated with a "v" or an "x"?
0

My working warkaround is:

  • expand the generated artifact (jar, war, ear, ...)
  • open (and decompile) the class file
  • put here the breakpoint

At this point IntelliJ fires breakpoints as expected.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.