本文介绍了尽管具有相同的Java/Gradle版本,但Gradle守护程序未重用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在以无特权的任意用户(没有/etc/passwd条目)在docker容器上运行gradle 5.6.2/Java 11,并通过 docker exec 进行构建.如果我通过 gradle --foreground 启动守护程序,然后运行 gradle build ,则尽管所有环境变量和配置都相同,但该守护程序始终被视为不兼容.Gradle让我知道至少一个守护程序选项不同,但是无法告诉我是哪个选项导致了该问题或提供了任何有用的上下文.从-info 输出中,我看不到任何显着差异:

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?

推荐答案

其他-add-opens 选项和 xms / xmx 值.在希望"和实际"行中查看 daemonOpts .

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.

使用-foreground 选项启动守护程序时,它将不评估您的项目.因此,将不会使用您在此处指定的任何选项(例如通过 org.gradle.jvmargs ).

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.

但是,您可以在启动守护程序之前,在 GRADLE_OPTS 环境变量中设置项目中使用的相同值.那应该使其兼容.但是,为什么要首先使用该选项?

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?

这篇关于尽管具有相同的Java/Gradle版本,但Gradle守护程序未重用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 21:25