Debugging ProjectConnection.getModel


(Andrew Sharp) #1

I’m using the Gradle Tools API to identify what tasks exist in some Gradle project. When I run

ProjectConnection.getModel(GradleProject.class);

I get an exception

org.gradle.tooling.GradleConnectionException: Could not fetch model of type
'CodeAssistModel' using Gradle distribution
'file:///opt/palantir/services/code-assist-worker/service/gradle-distributions/gradle-3.2-bin.zip'.

This exception is caused by

org.gradle.api.GradleException: Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at https://docs.gradle.org/3.2/userguide/gradle_daemon.html
Please read the following process output to find out more:

Java HotSpot™ 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

I found a daemon-281.out.log file in $gradleHome/daemon/3.2, it reads

21:50:48.480 [DEBUG] [org.gradle.launcher.daemon.bootstrap.DaemonMain] Assuming the daemon was started with following jvm opts: [-XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=US-ASCII, -Djava.io.tmpdir=var/data/tmp, -Duser.country=US, -Duser.language=en, -Duser.variant]
21:50:48.530 [ERROR] [system.err]
21:50:48.531 [ERROR] [system.err] FAILURE: Build failed with an exception.
21:50:48.537 [ERROR] [system.err]
21:50:48.538 [ERROR] [system.err] * What went wrong:
21:50:48.538 [ERROR] [system.err] Could not create service of type FileSystem using FileSystemServices.createFileSystem().
21:50:48.539 [ERROR] [system.err]
21:50:48.539 [ERROR] [system.err] * Try:
21:50:48.539 [ERROR] [system.err] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Daemon vm is shutting down… The daemon has exited normally or was terminated in response to a user interrupt.

I will guess that the -Djava.io.tmpdir=var/data/tmp may be the problem.

Is there some way we can run ProjectConnection.getModel so that --stacktrace, --debug, or --info will be passed to the daemon? Then we could be sure of the cause of this error. I have tried

ProjectConnection.model(...).withArguments("--stacktrace").get();

and this seems to have no effect.

Also, is there some way I can change the jvm opts that the daemon is launched with?

Thanks.