Hello good people. I am using the Gradle Tooling API from a custom Java application to analyze code in git repositories cloned to other folders on the disk.
When creating a ProjectConnection to a Gradle project using the Java and Gradle version as the application running itself there is no problem. When attempting to make a Gradle Connection using a different Java version the Tooling API seems to return the wrong daemon instead creating a correct one.
Note: I manually close all daemons using “./gradlew --stop” between each GradleProjection conection initalization. So there should be no active daemons running. This is an attempt to fix the problem.
Can anyone guide me to why the Tooling API would return the wrong daemon. Clearly some parts of the code knows which JDK it should be using, but the “daemon creation logic” determines something else.
Error from application run:
13:53:38 Caused by: org.gradle.launcher.daemon.client.DaemonConnectionException: The newly created daemon process has a different context than expected.
13:53:38 It won't be possible to reconnect to this daemon. Context mismatch:
13:53:38 Java home is different.
13:53:38 Wanted: DefaultDaemonContext[uid=null,javaHome=/usr/lib/jvm/java-1.8-openjdk,daemonRegistryDir=/home/jenkins/.gradle/daemon,pid=529,idleTimeout=null,priority=NORMAL,daemonOpts=--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.base/java.nio.charset=ALL-UNNAMED,--add-opens,java.base/java.net=ALL-UNNAMED,--add-opens,java.base/java.util.concurrent.atomic=ALL-UNNAMED,-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]
13:53:38 Actual: DefaultDaemonContext[uid=03828697-4412-444c-b413-50fba937c7e9,javaHome=/opt/java/openjdk,daemonRegistryDir=/home/jenkins/.gradle/daemon,pid=1899,idleTimeout=5000,priority=NORMAL,daemonOpts=--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-UNNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,--add-opens,java.base/java.nio.charset=ALL-UNNAMED,--add-opens,java.base/java.net=ALL-UNNAMED,--add-opens,java.base/java.util.concurrent.atomic=ALL-UNNAMED,-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=UTF-8,-Duser.country=US,-Duser.language=en,-Duser.variant]