Configuration on demand prevents the Tooling API from loading models


(Attila Kelemen) #1

When using the Configuration on demand feature in 1.4-rc-3 and attempting to load a model (via ‘ModelBuilder.get()’), the Tooling API blocks and waits indefinitely. I tried the feature by specifing ‘systemProp.org.gradle.configuration.ondemand=true’ in gradle.properties. I’m currently using version 1.0 of the Tooling API. Executing tasks through the Tooling API seems to work however.

Here are the logs produced by the daemon: http://pastebin.com/jXXDK9kL And here is the verbose console output: http://pastebin.com/NG2FpRC6

Another interesting thing is that if I interrupt (‘Thread.interrupt’) the thread executing the ‘ModelBuilder.get()’ call, the method call throws an NPE:

java.lang.NullPointerException
 at org.gradle.tooling.internal.consumer.protocoladapter.TargetTypeProvider.getTargetType(TargetTypeProvider.java:44)
 at org.gradle.tooling.internal.consumer.protocoladapter.ProtocolToModelAdapter.adapt(ProtocolToModelAdapter.java:31)
 at org.gradle.tooling.internal.consumer.DefaultModelBuilder$ProtocolToModelAdaptingHandler.onComplete(DefaultModelBuilder.java:114)
 at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onComplete(ResultHandlerAdapter.java:40)
 at org.gradle.tooling.internal.consumer.async.DefaultAsyncConnection$3.run(DefaultAsyncConnection.java:84)
 at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
[catch] at java.lang.Thread.run(Thread.java:662)

EDIT: I have verified this problem using the Tooling API 1.4-rc-3.

EDIT2: I have tested this problem with Eclipse, Idea and NetBeans:

  • Eclipse: It seems to use the version specified by the wrapper and if “Configuration on demand” is enabled and Gradle 1.4-rc-3 is set for the wrapper, it will wait endlessly when importing the project. It is a very serious problem for Eclipse because at this point the only thing you can do is to kill Eclipse, not even killing the Gradle daemon helps. - Idea: Idea seems to use Gradle 1.1 no matter what, so this problem does not affect Idea. - NetBeans: It is possible to configure what Gradle version you plan to use, but if you configure it to load a project using 1.4-rc-3, NB will load the project in the background forever. You can cancel the project loading (which will interrupt the thread loading the model, reporting the thrown NPE mentioned above) and you can continue working, but of course, the project remains unloadable with 1.4-rc-3.

#2

This is a known issue that won’t be fixed for the 1.4 release. However, you can try out the latest Gradle Nightly, where this issue should have been resolved.


(Attila Kelemen) #3

I have checked the latest nightly and it seems to work ok. However, it would be nice to also allow to apply configuration on demand even in the case of model loading. I have opened an RFE for this.


#4

Thanks for checking it out for us. I’ll make sure that your request makes it to the developer doing this work.