7

I'm debugging a Maven project in IntelliJ and I'm trying to figure out how to step into the source of one of my dependencies that's specified in my pom.xml. Specifically, my project has a dependency on Crawler4J I'm seeing some weird behaviour from Parser.parse(), and I want to step thru that method. I tried setting up a local cloned Git repo with the source and attaching it via the Sources option under Project Structure, but I still can't step into the compiled Crawler4J methods. As a long time C# developer (and relative Java nub) what I would have ideally liked is something like .NET Reflector's functionality for decompiling on the fly while debugging, but a way to attach the source would suffice.

3
  • 1
    With IntelliJ's maven support you can download and attach the sources on-the-fly - this should work out of the box. Did you import the project as a maven project (so that Idea nows about the pom)?
    – dratewka
    May 27, 2013 at 18:47
  • Oh, and you can also decompile but downloading the original sources is a better approach for maven artifacts.
    – dratewka
    May 27, 2013 at 18:49
  • Thanks! You're correct, as the answer below indicates as well. I appreciate the help. The decompile pointer may come in handy at some point as well.
    – Tyson
    Jun 4, 2013 at 4:02

1 Answer 1

5

I just set up the same dependency and I have no problems to download the source code.

enter image description here

Now I created a simple Main class with a Parser. I do Ctrl + Left-click and it will bring me to the Parser class.

enter image description here

As you can see it has a link in the upper right corner saying Download Sources.

enter image description here

After pressing that link the sources are downloaded and immediately available.

enter image description here

1
  • 1
    Thanks, this worked for me too. For some reason I wasn't initially shown the "Download Sources" option. Appreciate the help!
    – Tyson
    Jun 4, 2013 at 3:59

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.