Hacking Gradle internals - IDE integration


(Wujek Srujek) #1

Has anybody managed to setup the Gradle project itself in IDEA to be able to compile it, invoke it on some project and debug from within the IDE and so on? I am using the ‘idea’ task from Gradle and I can open the project in IDEA but it doesn’t build for multiple reasons (cycle in module deps, some import errors even though the imported classes are there, some Groovy stubs problems, and so on). How do you hack Gradle internals? The way I’ve been doing it (because of the above) was to change gradle, compile a class or two, replace it in my distribution and do remote debugging - this is not really manageable for obvious reasons. I am using IDEA 12.1.4, the latest stable.

wujek


(Luke Daley) #2

All of the Gradle developers use IDEA on a day to day basis. What version of IDEA are you using?


(Wujek Srujek) #3

IDEA Ultimate 12.1.4.


(Luke Daley) #4

In the project settings preferences, make sure you have “Use external build” unticked under the “Compiler” section.


(Wujek Srujek) #5

Thanks for the tip. It does fix some issues, but I still get some problems with Groovy stubs. I guess you have a long-existent project in IDEA that just works for you, but you would also have some trouble importing it from scratch. Have you tried that? Do you have any problems with it? If not, then it must be something wrong with my setup. I do have the same problems on two different machines / two different OSes, though. In the meantime, I just wrote a couple of scripts / shell aliases that are the next best thing to IDE support and I can rebuild the project that I’m hacking on and replace it in a local installation created from the sources, and do remote debugging. It’s not perfect but does work.


(Luke Daley) #6

I rebuild my IDEA project about once a month.

I do get issues with IDEA’s Groovy stub compiler sometimes, but “Rebuild Project” followed by persistently trying to the run the test always resolves it.

What are the exact issues/errors you are having?


(Wujek Srujek) #7

Aaaah, I got it. I was using the GradleMain configuration and didn’t see there are others, the ‘Gradle’ one works. GradleMain does not:

Exception in thread "main" java.lang.ClassNotFoundException: org.gradle.launcher.GradleMain
 at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
 at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:190)
 at com.intellij.rt.execution.application.AppMain.main(AppMain.java:113)

Seems like the classpath is wrong (set to module wrapper), apparently it doesn’t have everything it needs.