An Eclipse user in IDEA-land

I am an Eclipse user for more than 3 years, but I find it interesting to have a look at the other approaches in the world of Java IDEs. This post is not meant to start once again the long and so useless discussion about which one is the best, but rather to ask questions about how to achieve some goals (and hopefully have some advanced users answer ’em [smile/]).

Since back in the days of Netbeans 3, I got used to define in my workspace projects that are related to my current work. For example, if my current work project is using WebWork than usually I will create a WebWork project. This will allow me to navigate through its sourcecode and also help me when debugging.

IntelliJ IDEA allows you to work with a project at a time. But it allows you to define more modules inside a project and as I found out groups of modules. And here is my first question:

Can I use modules to refere the external projects my current project is based on? Or in case this is a wrong approach from the perspective of IDEA than what is the way to define my project so that I can navigate the source code of the projects it depends on?

I will be very happy to hear how I can do this in the IDEA-way. Thanks in advance to everyone giving me hints.

Disclaimer: I have spent some time reading the IDEA help, but I haven’t found references to this question. The approach I am describing above it’s coming mainly from using the Eclipse workspace export plugin provided with IDEA.

Update: Scott posted the hint to succesfully see the dependency projects while debugging.

category: , ,



Filed under Uncategorized

4 responses to “An Eclipse user in IDEA-land

  1. Scott Mitchell

    The way I accomplish this in IDEA is to attach source to the JAR files. Go into your module settings, then the libraries tab. Select the JAR file in question, and then click “Attach Sources” and navigate to the source folder for that project. Then you will be able to navigate into the source code for any class in that JAR.

  2. the_mindstorm

    Thanks Scott. This indeed will allow to see the source when debugging. Still, I don’t think that using this method will allow me to see the sourcebase in the project view (the same way I can navigate my project).

  3. Rob Harwood

    If all you want to do is see the source, but not compile it, then adding sources to a library/jar is the right option. If you actually want to edit the source and also have it compile, then you have two options: Add content roots and source folders to an existing module, or create a separate module and configure its content/source roots. You do all of this in the Modules settings dialog. To start with, I’d just add content/source roots to an existing module. If you later see that you need to split it off into its own module, that’s easy enough to do. There is also a way to ‘exclude’ folders from a content root, but in that case you also can’t see the sources. Judicious use of modules can allow for nearly any project structure. Also, for large or complex projects, judicious organization of modules can improve searches, code completion speed, etc. It’s a little bit of an art form, you just have to play with it, I think.

  4. Nit

    I tried using adding external sources to a library/jar and trying to debug my test but i cant go into my source code it show me source not found and showing me button for “Edit Source lookup path”.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s