Can't call evaluate() on Project instances returned from ProjectBuilder with gradle-1.12-rc-1

Example project that demonstrates the issue

Calling evaluate() on Project instances built using ProjectBuilder causes a NoClassDefFound exception inside Gradle:

‘’’ java.lang.NoClassDefFoundError: org/gradle/tooling/internal/impl/DefaultGradleProject

at org.gradle.plugins.ide.internal.tooling.ToolingRegistrationAction.execute(

at org.gradle.plugins.ide.internal.tooling.ToolingRegistrationAction.execute(

at org.gradle.configuration.project.PluginsProjectConfigureActions.execute(

at org.gradle.configuration.project.PluginsProjectConfigureActions.execute(

at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(

at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(

at org.gradle.api.internal.project.AbstractProject.evaluate(

at org.gradle.api.internal.project.AbstractProject.evaluate(

at BreakingTest.can evaluate ProjectBuilder(BreakingTest.groovy:15) Caused by: java.lang.ClassNotFoundException: org.gradle.tooling.internal.impl.DefaultGradleProject



at java.lang.ClassLoader.loadClass(

at sun.misc.Launcher$AppClassLoader.loadClass(

at java.lang.ClassLoader.loadClass(

… 9 more ‘’’

If I switch back to gradle-1.11 there’s no issue.

This is indeed a bug that we should fix prior to the release. Thanks for excellent report!

Just so you know, the 'evaluate() 'method is internal (it’s not declared on ‘Project’, it just happens to be on the internal implementation). This means it may change, move or break at any time. You generally should avoid using internal methods.

Fair enough. Is there another method for testing things that require the project to be in an evaluated state? We could use the Tooling API, but that doesn’t allow us to inspect the project state and seems overkill for unit testing purposes.

Perhaps something could be put into 2.0 to disallow calling internal methods not exposed by the gradle interfaces. Delegating proxies spring to mind…

Please don’t. Use cases come up that the Gradle developers can’t anticipate, which are possible if we can call internal methods. The project is open source, we can see the method we need and can adapt when they change. If methods become un-callable, we’ll be forced to fork Gradle just to make method available. I think it’s understood that calling internal methods isn’t supported.

@jason, You shouldn’t need to use evaluate() to configure the project, you can just drive it from your test as you would from a build script.

@justin, I was thinking that preventing usage of the private API would force the public API (interfaces) to improve more rapidly.

Is there a way to force an evaluation via the public api? I have one part of our large build which simply doesn’t work if I have configure-on-demand=true. I’d like to be able to force evaluation of all sub-projects if this one task gets executed. So, basically, I’d like to turn configure-on-demand on/off dynamically.