0
votes

I'm running gradle 5.6.2/Java 11 on a docker container as an unprivileged arbitrary user (no /etc/passwd entry) and building via docker exec. If I start the daemon via gradle --foreground and then run gradle build, the daemon is always deemed incompatible despite all environment variables and configuration being the same. Gradle lets me know At least one daemon option is different but fails to tell me what options are causing the issue or provide any useful context whatsoever. From the --info output, I cannot see any significant difference:

Found daemon DaemonInfo{pid=2349, address=[faff1188-7330-4666-8735-46fd97109411 port:33491, addresses:[/127.0.0.1]], state=Idle, lastBusy=1571244832816, context=DefaultDaemonContext[uid=ba368fe6-ab22-4d82-8780-a1b58dd80baf,javaHome=/usr/lib/jvm/adoptopenjdk-11-
hotspot-amd64,daemonRegistryDir=/var/gradle/daemon,pid=2349,idleTimeout=10800000,priority=NORMAL,daemonOpts=-Xms64m,-Xmx64m,-Dfile.encoding=US-ASCII,-Duser.country=US,-Duser.language=en,-Duser.variant]} however its context does not match the desired criteria.
At least one daemon option is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64,daemonRegistryDir=/var/gradle/daemon,pid=2416,idleTimeout=null,priority=NORMAL,daemonOpts=--add-opens,java.base/java.util=ALL-UNNAMED,--add-opens,java.base/java.lang=ALL-U
NNAMED,--add-opens,java.base/java.lang.invoke=ALL-UNNAMED,--add-opens,java.prefs/java.util.prefs=ALL-UNNAMED,-XX:MaxMetaspaceSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xms256m,-Xmx512m,-Dfile.encoding=US-ASCII,-Duser.country=US,-Duser.language=en,-Duser.variant
]
Actual: DefaultDaemonContext[uid=ba368fe6-ab22-4d82-8780-a1b58dd80baf,javaHome=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64,daemonRegistryDir=/var/gradle/daemon,pid=2349,idleTimeout=10800000,priority=NORMAL,daemonOpts=-Xms64m,-Xmx64m,-Dfile.encoding=US-ASCII,-Dus
er.country=US,-Duser.language=en,-Duser.variant]

  Looking for a different daemon...

How can I ensure my foreground daemon gets used -instead of having a new daemon start on each build and wasting excessive amounts of time?

1

1 Answers

0
votes

There are differences in both the additional --add-opens options and in the xms/xmx values. Look at the daemonOpts in the "Wanted" and "Actual" lines.

When you start a daemon with the --foreground option, it will not evaluate your project. So any options you have specified here (e.g. through org.gradle.jvmargs) will not be used.

However, you can set the same values used in your project in a GRADLE_OPTS environment variable before starting the daemon. That should make it compatible. But why are you using that option in the first place?