Keen to try Gradle integration in IntelliJ IDEA?
You asked us to add Gradle support to IntelliJ IDEA. And when you ask hard we usually respond. So, we’ve been working hard on that lately. The job is still in progress but the most impatient ones can already try what is done.
The most valuable thing IntelliJ IDEA does now is setting up the project (modules, libraries, etc.) on the basis of a Gradle project file. The process is rather simple:
1. Choose the target Gradle project:
2. Check and, if necessary, adjust its settings prior to import:
3. Voila, the project is ready to use:
The plugin will be available when IntelliJ IDEA 11 EAP opens but if you really can’t wait, check this wiki page for instructions on how to build IntelliJ IDEA and Gradle plugin from the sources. It also shows current development status.
Your feedback is much appreciated on the discussion forum or in IntelliJ IDEA issue tracker.
I'm off to a vacation for 2 weeks and hope to get your feedback when I return refreshed to take care about it :)
Frankly says:
September 8, 2011I don’t understand why Jetbrains is working on features like this that few people will use instead of working on IntelliJ performance problems.
Christian says:
September 9, 2011That is great news, thanks!
Will the gradle integration provide advanced editing support for gradle build scripts (like autocompletion)?
Eugene Toporov says:
September 9, 2011@Frankly
1. We listen to the votes: http://youtrack.jetbrains.net/issues/IDEA?q=%23Unresolved+order+by%3A+votes+
2. Believe us, not the entire JetBrains works on this particular feature. Performance is being taken care of too, constantly.
Frankly says:
September 9, 2011That’s good to hear. Voting doesn’t work very well for performance issues because usage models vary greatly from user to user. For example, I use Remote Desktop Connection heavily which is much slower under IDEA 10 than 9, so while all my coworkers who don’t work remotely have upgraded to 10, I’m still using 9.
Ryan says:
September 12, 2011I was going to try this, but when I attempt to open a Gradle project, I get the error:
Can’t resolve target gradle project at…..
Reason: Gradle version contains incomplete tooling API
I tried with the nightly gradle builds from Sept 8th and Sept 13th. Any ideas? I’ve never build IDEA CE before and have never used Gradle, so it might be a simple oversight on my part.
Also, the toolingAPI build.gradle file does not contain:
apply plugin: ‘idea’
..so the instructions relating to the tooling API on the wiki page may be incomplete.
Rod says:
September 20, 2011I have the same problem as Ryan. I’ve tried with different versions of Gradle, and I’ve verified the gradle-tooling-api jar is in lib. No matter what, the project won’t build.
Denis.Zhdanov says:
September 21, 2011I asked gradle guys to have a look on that. The tooling API jar should contain idea-specific classes like IdeaProject, OfflineIdeaProject etc.
Denis
xu wei says:
September 23, 2011I could not wait for this plugin, what’s the release plan?
Szczepan Faber says:
September 25, 2011Hey Denis,
Tooling api jar does contain idea-specific classes. The problem is that OfflineIdeaProject has been renamed to BasicIdeaProject a couple of weeks ago. I could have communicated it more explicitly, sorry 🙂 The thing is we only guarantee the tooling API does not change between releases. Milestone-5 should be out soon and I think it would be good if the gradle idea plugin actually shipped with the tooling api jar (currently it is a ‘provided’ dependency).
When I fixed the code to refer to BasicIdeaProject instead of Offline things still didn’t work out. The exception I’m facing is:
Caused by: java.lang.NoClassDefFoundError: com/intellij/openapi/projectRoots/JavaSdkVersion
It does not seem to be related to the tooling api because this class comes from the IDEA’s openapi module and it does not have any dependencies to the tooling api.
So, to resolve the issue we should:
– update the version of tooling-api gradle plugin uses now
– use BasicIdeaProject instead of Offline
– fix the remaining issues (I stopped at NoClassDefFoundError with JavaSdkVersion)
Cheers!
John Hurst says:
September 25, 2011Hi,
Just to add another voice, I also have the “Gradle version contains incomplete tooling API”.
I’m using gradle-1.0-milestone-3, and have been using “apply plugin: ‘idea'” to generate my IDEA .iml files. It’s weird that milestone-3 came out in, what, April?, and there has been no further update since. Wonder what’s up with that.
John Hurst
Denis.Zhdanov says:
September 26, 2011Hi all, I’m back.
Just adapted the changes at the gradle and intellij idea api to the gradle plugin. ‘Import project’ works for me now (tested against gradle v. 1.0-milestone-5-20110926003039+0200).
Feel free to rebuild intellij idea from sources or wait for the next EAP to try the plugin.
Denis
Steinar Haugen says:
September 28, 2011About the Gradle DSL
I see the comments on the wiki about the gradle DSL syntax highlighting and completion: http://confluence.jetbrains.com/display/IDEADEV/Gradle+integration
Gradle DSL Syntax highlighting is nice. Completion is better. But what about Quick Doc Lookup (Ctrl-Q). The Gradle DSL doc is actually very good, and it would be excellent it it was possible to access it with Quick Doc lookup instead of through a browser.
I haven’t been able to find any info about it, though. Is it even considered as feature at this point?
Denis.Zhdanov says:
September 29, 2011Excellent idea, thanks! Will put it to the list.
BarryMac says:
October 14, 2011Fantastic work! always with the cutting edge features , that why Intellij is one of the only pieces of software I continue to pay for
Denis.Zhdanov says:
October 15, 2011Thanks!
Ryan says:
October 18, 2011I tried the new EAP today. The import seems to work quite well. A few observations…
I couldn’t get the Gradle GUI to work, so I assume that part hasn’t been implemented yet.
My project ended up configured to use a 1.7 JDK when I selected a 1.6 JDK during import. I imported my old IDE settings on first run, so maybe that had something to do with it.
I had to update the compiler resource pattern to include some extra file types before the built in compiler would work. I still use the built in compiler for running tests as I’m working. Since gradle handles resource patterns by module, I don’t think it’s practical to try to resolve them during the import. I think ‘gradle idea’ sets it up to exclude .groovy and .java files and includes everything else.
As a use case I have a UI module in my project that uses ‘src/main/java/**/resources/**’ in addition to the normal convention.
One thing I always find myself doing when I import Maven projects is adding run configurations for the UI module(s). It would be very cool if the Gradle import could detect modules using the application plugin and automatically add a related run configuration for each.
Something even cooler would be an option to import all tasks from *.favorite-tasks as run configuration during the import.
Another wishlist feature would be an option to exclude all IDEA files from version control during the project import. When I import a Maven project the first thing that happens after import is that I get asked if I want to include the generated IDEA files into SVN – one dialog per module. I always select ‘don’t ask again’ and then immediately go into setting to ignore the file type (*.iml IIRC) and re-enable the prompt I just disabled.
That’s all I can think of for now. Keep up the good work!
opticyclic says:
October 18, 2011For someone who is new to gradle, auto-completion and quick doc look up are the highest priorities for me.
Denis.Zhdanov says:
October 20, 2011@Ryan: thanks for the feedback!
I’ll check JDK processing on import and yes, no gradle tool window is provided within the plugin yet.
Regarding compiler exclusion patterns – don’t see that they are supported by gradle at the moment – http://www.gradle.org/current/docs/userguide/idea_plugin.html. http://issues.gradle.org/browse/GRADLE-1846, http://issues.gradle.org/browse/GRADLE-1847 and http://youtrack.jetbrains.net/issue/IDEA-75723
Run configurations – cool, I’ve created http://youtrack.jetbrains.net/issue/IDEA-75722
VCS – agree, see http://youtrack.jetbrains.net/issue/IDEA-75724
Barry Becker says:
November 23, 2011I just installed the latest Intellij 11 beta and tried to use the gradle plugin to create a new project based on the latest Gradle (1.0m6) multiproject example (as your screenshots also show). The structure of the project shows up on the third step of the wizard correctly, but when I click Finish, I get this exception.
Error during dispatching of java.awt.event.MouseEvent[MOUSE_CLICKED,(117,213),absolute(392,200),button=1,modifiers=Button1,clickCount=1] on frame0
java.lang.NullPointerException
at org.jetbrains.plugins.gradle.importing.GradleProjectImportBuilder.commit(GradleProjectImportBuilder.java:99)
at com.intellij.projectImport.ProjectImportBuilder.commit(ProjectImportBuilder.java:56)
at com.intellij.ide.impl.NewProjectUtil.createNewProject(NewProjectUtil.java:143)
at com.intellij.ide.actions.NewProjectAction.actionPerformed(NewProjectAction.java:26)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreen$ActionGroupDescriptor$3.onPress(WelcomeScreen.java:753)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreen$ButtonWithExtension.onPress(WelcomeScreen.java:902)
at com.intellij.openapi.wm.impl.welcomeScreen.WelcomeScreen$ActionGroupDescriptor$2.mouseClicked(WelcomeScreen.java:697)
at java.awt.Component.processMouseEvent(Component.java:6291)
Denis.Zhdanov says:
November 24, 2011Thanks, I’ve created ticket http://youtrack.jetbrains.net/issue/IDEA-77528
Barry Becker says:
December 3, 2011I just installed the Idea11RC and it works great! Thanks for fixing the exception I reported in the beta.
Some minor things:
– I was kind of hoping that I would see a “Gradle build” button on the right that I could configure based on a build.gradle file the way I can configure “Ant build” based on build.xml ant file, and have all the tasks show up. I was able to run or debug tasks by right clicking on them, or add gradle tasks as configurations at the top, so that is very nice.
– I see “cannot resolve” errors on these two lines in the sample 1.06m1 multiproject/api/build.gradle file
org.apache.commons.math.fraction.Fraction lhs = new org.apache.commons.math.fraction.Fraction(1, 3);
org.gradle.buildsrc.BuildSrcClass bsc = new org.gradle.buildsrc.BuildSrcClass()
– You get a 404 error when you click on help from Tools | Task | Open… | Configure | Help button.
– I don’t see the svn 1.7 experimental plugin listed anymore, and can’t find how to get it.
Denis.Zhdanov says:
December 6, 2011Hi Barry,
* ‘sync gradle and IJ project structure’ is under progress. The ‘gradle’ plugin will be available for downloading when the feature is done – http://youtrack.jetbrains.net/issue/IDEA-76142;
* build.gradle editing will also be supported;
* please submit corresponding ticket to the tracker;
* not sure about that. Please ask the question at the corresponding ticket’s context – http://youtrack.jetbrains.net/issue/IDEA-72400
Hans says:
December 7, 2011I just upgraded to IntelliJ 11 and now my runconfigs are broken. Gradle just outputs:
(even if I configured ‘test’ as my script parameter). It seems that Gradle is not receiving that script param…. What am I doing wrong?
——
:help
Welcome to Gradle 1.0-milestone-6.
To run a build, run gradle …
To see a list of available tasks, run gradle tasks
To see a list of command-line options, run gradle –help
BUILD SUCCESSFUL
Total time: 2.289 secs
Process finished with exit code 0
Denis.Zhdanov says:
December 7, 2011Hi Hans,
I’ve created corresponding ticket – http://youtrack.jetbrains.net/issue/IDEA-78430
Please register such problems directly at the tracker instead of mentioning them at blog comments.
Denis