IntelliJ PEBKAC
I’ve been trying out IntelliJ IDEA on my latest project and I ran into an issue that made IDEA unusable for me.
I’ve been bouncing between Eclipse and IntelliJ on my last two projects. I’ve been using Eclipse because that’s the “blessed” IDE by my client and used by my team. I’ve been using IntelliJ (or should I call it IDEA? I’m never quite sure…) because its the IDE I should like.
Right now, I think I’m in a unique position as I’m passionate about neither IDE and can hopefully form an objective opinion about them. I’ll post my thoughts as time permits.
But, first… my PBKAC issue (yes… that’s Problem Exists Between Keyboard And Chair
). My current project is using Maven as a build tool (which is working great for us so far). Although we’re only building a Web Application, since we’re using Websphere and it prefers to deploy EAR files over simple WAR files, I went ahead and setup our Maven project to have several subprojects (one for the WAR and one for the EAR) all under a master project. That said, for our day to day development we’ve been using Tomcat and as such, only interested in WAR deployments most of the time.
This is all working great with Eclipse (using the excellent MyEclipseIDE plugins) - hot deployment works very well. I have two projects setup in Eclipse for the WAR and the EAR packaging, but 99% of the time I ignore the EAR project.
When I imported the project into IntelliJ I used its Maven project import capability and it worked flawless. I thought I was all set. I did a build and configured my project to follow this guide (which is poorly documented in IntelliJ itself).
I fired up Tomcat in debug mode and started trying to work on a JSP and controller code. But, IntelliJ just ground to a halt everytime I toggled between the browser and it. I could see that it was copying tons of files around (JARs in particular) when I made a simple change and it took 10 ~ 15 seconds for simple JSP changes to show, even longer for code changes. To make matters worse, IDEA would lock up and not paint itself when I toggled back from the browser for tens of seconds. It just wasn’t acceptable - especially given how smooth it worked in Eclipse. I couldn’t figure it out… I mean if everybody loves this IDEA it should certainly be able to do hot deploy better than this.
I talked with my colleagues who use IntelliJ and they were perplexed as well.
Despite rechecking my settings several times, Googling and even downgrading to IDEA 7.0.4 (from the shinny new 8.0.0 release) I couldn’t get it to work. I was about to give up on IntelliJ and settle on Eclipse when I stumbled on the problem.
As I said earlier, I have two projects in Maven (modules in IntelliJ) for the WAR and EAR (the latter used only for Websphere) and I pretty much ignore the EAR project when doing interactive development. It turns out that although I was ignoring it, IntelliJ wasn’t!
By default, when IntelliJ imports a Maven project with EAR packaging it will build an EAR file. In my project, the EAR file contains everything. Everytime I made a change, IntelliJ was dutifully rebuilding that EAR file (a very expensive operation). That was making IDEA run so slow.
Most of this is truly a PEBKAC issue - I should’ve looked at the EAR module settings. Part of it is getting used to the nature if IDEA projects and modules. I was thinking of modules as being the equivalent of Eclipse projects, but… that’s not quite true. When you tell IntelliJ to build the project, it builds all the modules - duh! Part of the problem is the “model” IntelliJ uses in that I’m telling it to deploy, run, debug, hot swap, etc my Web Module so my focus is only on the Web Module. why should the EAR module be involved? And lastly… part of it is just that Java Web Development can be rather involved with a lot of (too many!!) moving parts.