Latest & Greatest tips
Running the gradle build from IDEA against arbitrary project
- Why is it useful? Because it allows troubleshooting problems with builds via java debugger.
- Pull gradle into idea ('gradle idea') if you haven't yet
- Create & run/debug following class:
Old tips (dated!)
Below information is dated! It still contains valuable tips I think. However, some classes/properties do not exist any more. You've been warned.
Once you have setup your Gradle project in IntelliJ you can run any Gradle build directly from IntelliJ via Gradle's BootstrapMain class. For example if you have a Gradle project, where <someGradleProjectDir> is the location of the Gradle project, you can set up a Run/Debug configuration like this:

In the Program Parameter field you can write everything what you would enter on the command line when running Gradle. It then delegates to the Main class. To run our builds from IntelliJ we make use of the Gradle -p option, which allows you to specify the location of a Gradle build (defaults to current dir). See below to learn more about the other arguments.
You can also run the Gradle build itself from IntelliJ. We use this often to solve chicken-egg problems when we first use a new incompatible feature in our Gradle build. Here is a Run/Debug configuration for building Gradle:

Here is the list of JVM arguments I'm using:

gradle.bootstrap.debugis a system property to enable logging console debug output. This is output from the bootstrap process, which takes place before the logging libraries are available and configured.- if
gradle.bootstrap.gradleBinis set, the value of this property is interpreted as a file system path to a directory with the compiled Gradle production code. If this property is set, gradle binary jars possibly found in the gradle home lib are not put in the classpath. - We set gradle home to be our top level source project folder. This has one and only one purpose. BootstrapMain looks for a folder named
libin gradle home to put the contained libraries in the classpath. As the source project has also a folder names lib with the project libraries this works. But it works only in conjunction with thegradle.bootstrap.gradleBinproperty, as the source project lib folder does of course not contain the gradle binary jars.
Here is the list of program arguments:

- It is important to note that we use the
loption here. By default Gradle looks for the plugin properties file in gradle home. But in our set up it would not find one there. Therefore we have to specify a location where the current one can be found. The same is true for theKoption.
With this setup we can run Gradle without the necessity to have a Gradle distribution installed somewhere. This is wonderful for debugging and solving hen-egg problems. But before we submit any changes, we always use an regular installed Gradle distribution to build Gradle and run the unit and integration tests.
To learn more about the install task have a look at: http://gradle.org/build.html

