Contributing to Gradle: how to use IntelliJ?

I followed the instructions in the https://github.com/gradle/gradle/blob/master/README.md page, and tried several times already to have something working in the IDE (IntelliJ 12.1.6 on OSX 10.8.5, also tried it before on a Windows box) but it has always failed.

What are the actual steps to be able to build gradle from the IDE and run tests from the IDE?

Here is the output when simply launching ‘gradlew idea’, opening the generated IntelliJ project, and clicking Build - Make Project:

Information:Using javac 1.7.0_40 to compile java sources

Information:java: Errors occurred while compiling module ‘internalIntegTesting’

Information:Compilation completed with 13 errors and 6 warnings in 5 sec

Information:13 errors

Information:6 warnings

/Users/jb/projects/gradle/subprojects/internal-integ-testing/src/main/groovy/org/gradle/integtests/fixtures/executer/AbstractGradleExecuter.java

Error:Error:line (39)java: cannot find symbol

symbol:

class Matchers

location: package org.gradle.util

Error:Error:line (603)java: cannot find symbol

symbol: method matchesRegexp(java.lang.String)

Error:Error:line (618)java: cannot find symbol

symbol: method matchesRegexp(java.lang.String)

Error:Error:line (619)java: cannot find symbol

symbol: method matchesRegexp(java.lang.String)

/Users/jb/projects/gradle/subprojects/internal-integ-testing/src/main/groovy/org/gradle/integtests/fixtures/executer/OutputScrapingExecutionFailure.java

Error:Error:line (24)java: cannot find symbol

symbol:

class Matchers

location: package org.gradle.util

Error:Error:line (24)java: static import only from classes and interfaces

Error:Error:line (118)java: cannot find symbol

symbol:

method isEmpty()

location: class org.gradle.integtests.fixtures.executer.OutputScrapingExecutionFailure

/Users/jb/projects/gradle/subprojects/internal-integ-testing/src/main/groovy/org/gradle/integtests/fixtures/executer/InProcessGradleExecuter.java

Warning:Warning:line (20)java: org.gradle.GradleLauncher in org.gradle has been deprecated

Error:Error:line (62)java: cannot find symbol

symbol:

class Matchers

location: package org.gradle.util

Error:Error:line (62)java: static import only from classes and interfaces

Error:Error:line (63)java: cannot find symbol

symbol:

class Matchers

location: package org.gradle.util

Error:Error:line (63)java: static import only from classes and interfaces

Warning:Warning:line (167)java: org.gradle.GradleLauncher in org.gradle has been deprecated

Warning:Warning:line (167)java: getFactory() in org.gradle.GradleLauncher has been deprecated

Warning:Warning:line (171)java: org.gradle.GradleLauncher in org.gradle has been deprecated

Error:Error:line (393)java: cannot find symbol

symbol:

method hasMessage(org.hamcrest.Matcher<java.lang.String>)

location: class org.gradle.integtests.fixtures.executer.InProcessGradleExecuter.InProcessExecutionFailure

Error:Error:line (414)java: cannot find symbol

symbol:

method isEmpty()

location: class org.gradle.integtests.fixtures.executer.InProcessGradleExecuter.InProcessExecutionFailure

/Users/jb/projects/gradle/subprojects/internal-integ-testing/src/main/groovy/org/gradle/integtests/fixtures/executer/OutputScrapingExecutionResult.java

Warning:Warning:java: Some input files use unchecked or unsafe operations.

Warning:Warning:java: Recompile with -Xlint:unchecked for details.

Opening the project structure also shows an error signalling circular dependencies between modules.

Try to uncheck the checkbox in IntelliJ IDEA > Preferences… > Compiler > Use external build.

It goes further with this checkbox unchecked, but still doesn’t build.

First error: The stubs generated by IntelliJ for JUnitTestClassProcessorTest don’t compile. IntelliJ suggests excluding this file from stub generation. That’s what I did.

Then I get a second set of errors:

/Users/jb/projects/gradle/subprojects/core/src/test/groovy/org/gradle/util/SingleMessageLoggerTest.groovy

Error:Error:line (29)cleanup() in org.gradle.util.SingleMessageLoggerTest cannot override cleanup in org.gradle.test.fixtures.concurrent.ConcurrentSpec; attempting to assign weaker access privileges; was public

/Users/jb/projects/gradle/subprojects/messaging/src/test/groovy/org/gradle/messaging/actor/internal/DefaultActorFactorySpec.groovy

Error:Error:line (28)cleanup() in org.gradle.messaging.actor.internal.DefaultActorFactorySpec cannot override cleanup in org.gradle.test.fixtures.concurrent.ConcurrentSpec; attempting to assign weaker access privileges; was public

/Users/jb/projects/gradle/subprojects/core-impl/src/integTest/groovy/org/gradle/integtests/resolve/caching/CachedDependencyResolutionIntegrationTest.groovy

Error:Error:line (34)setup() in org.gradle.integtests.resolve.caching.CachedDependencyResolutionIntegrationTest cannot override setup in org.gradle.integtests.fixtures.AbstractDependencyResolutionTest; attempting to assign weaker access privileges; was public

For the second issue I am not sure why it is happening but it usually goes away if you “Make” the second time.

Ah, yes indeed. It builds fine now, an I can run tests from the IDE. Thanks a lot!

The checkbox unchecking would be worth automating in the idea task, and the other two glitches (excluding the test class from stub generation, and the double compilation) would be worth documenting in the README, IMHO.

I agree. It definitely should be mentioned in the README file.

The checkbox unchecking would be worth automating in the idea task

Absolutely.

and the other two glitches (excluding the test class from stub generation, and the double compilation) would be worth documenting in the README, IMHO.

These should go in Contributing.MD, which the readme should link to.

Any and all pull requests greatly appreciated!

Here’s the pull request: https://github.com/gradle/gradle/pull/212

Since I managed to automate everything except, obviously, the need to build twice, I just added a note aboyt that in the README, where the instructions about IDEA project generation already are.

Many thanks :slight_smile: