Tuesday, January 5, 2010

IDEA 9, Gradle and Eating Your Own Dogfood

After reading the comment on a post a few weeks ago regarding Intellij 9 and Gradle, I had to laugh. Having worked on open source projects for 15+ years and presenting at countless conferences and user groups, I have stated roughly the same comment countless times... "It's open source, if you don't like it or you want a change, then do it!". Thanks to Peter for the suggestion and encouragement. It clearly seems that my actions were a surprise as Peter's first comment in a private email exchange was "Great you're doing this!"

Intellij 9 Development Experience
Getting the source and setting up for the first run was fairly painless after you find the download information. It was nice to see that the code repository was git. I ran into 2 issues in getting setup:
  1. Git clone failed with an unclear message initially. It turned out I was trying to clone using the git protocol behind a corporate firewall which was blocking it. As soon I was not behind the firewall, all went well. Be prepared... it is 924 MB.
  2. Setting up the run configuration wasn't complex, but it wasn't as advertised.

Here is what the Building and Running from the IDE from the checkout and build page should read:
  • Open the project as a "new" directory-based project
  • Configure a JSDK named "IDEA jdk", pointing to an installation of either JDK 1.6 (recommended) or JDK 1.5. This is on the project tab of the project structure.
  • Increase the compiler heap size... default is 128M, it works with 512M :)
  • Use Build | Make Project to build the code
  • To run the code, use the provided shared run configuration "IDEA".

Important notes:
  1. You will see that there are circular dependencies between 4 of the project modules.
  2. With the default compiler heap size, you will get a compilation error ( which is erroneous )
  3. There are a number of deprecation warnings during compilation... this might be a great place for someone to get involved and do some clean up.

After you have an Intellij running another instance of Intellij :) Here is a list of resources to be familiar with:
  1. Source Repository Layout
  2. View PSI structure (under the tool menu) - PSI is an IDEA AST abstraction, which was the toughest learning curve. Learn it! Then look at the following clases and their usage in the code base: PsiUtilBase, PsiUtil, PsiResolveHelper, PsiResolveHelperImpl

End Result
In the end, I spent 4 hours adding in additional gradle task support into Intellij 9, created a patch and submitted to Peter... a few days later I was informed that it was committed to repository. Enhanced Gradle support is on it's way!

I had mixed feels when IDEA announced it was going open source, but now that it is... Let's get in there and make this an even better editor!

Kudos to JetBrains and it's community!

8 comments:

Trond Andersen said...

I've used Gradle for a project, but during development I run with an exploded web directory for efficiency. I had to sign an applet as part of the build to the exploded directory. I could only use ANT og Maven targets to be run during this build. Would have been great if one could add Gradle tasks instead. I had to add a simple ANT file in order to do this.

Any thoughts on the complexity to add this functionality?

phil swenson said...

how do we get a hold of your modifications?

台中 said...
This comment has been removed by a blog administrator.
Ken Sipe said...

@phil
It should be committed on IDEA git repo... if you would prefer it from me, let me know. I'll put it on github.

Taras Tielkes said...

I've just started using Gradle.
Thanks for providing the patch!

Alexander said...
This comment has been removed by the author.
Alexander said...

Hi Ken.
I can't find new gradle syntax support (apply plugin instead usePlugin, task instead createTask) on idea trunk. (I looked into org.jetbrains.plugins.groovy.gradle package at groovy plugin).
For example, it uses PsiUtil.isMethodCall((GrMethodCallExpression)parent, "createTask") to lookup for custom tasks.
Can you point me to the location of your patch (maybe it is overrided somehow or moved to another location or so).

copdresses said...

I've used Gradle for a project, but during development I run with an exploded web directory for efficiency. I had to sign an applet as part of the build to the exploded directory.Launch x431