gpt4 book ai didi

java - 对于某些任务,Gradle 执行会卡住 3 分钟

转载 作者:行者123 更新时间:2023-12-01 13:45:42 29 4
gpt4 key购买 nike

我有 2 个相对简单的 Gradle 6.1.1 配置,一个是使用 https://plugins.gradle.org/plugin/com.github.node-gradle.node构建一个react app,另一个基于https://plugins.gradle.org/plugin/com.bmuschko.tomcat并在嵌入式 tomcat 中运行一个简单的 wicket 应用程序。

npm 任务的第一个配置是:

apply plugin: 'com.github.node-gradle.node'
node {
version = '12.16.0'
download = true
workDir = file "$project.buildDir/nodejs"
}

task "npmBuild"( type:NpmTask ) {
args = [ 'run', 'build' ]
}

并在 Windows 10 中产生以下输出:
>gradlew.bat npmBuild
Starting a Gradle Daemon (subsequent builds will be faster)

> Task :npmBuild

> layer-selection@0.1.0 build .....
> react-scripts build

Creating an optimized production build...
Compiled with warnings.

...
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

File sizes after gzip:

90.99 KB build\static\js\2.17f9cda1.chunk.js
28.68 KB build\static\css\2.2f7f14af.chunk.css
3.43 KB build\static\js\main.1150707e.chunk.js
778 B build\static\js\runtime-main.989054bd.js
177 B build\static\css\main.f7c0afb8.chunk.css
...
Find out more about deployment here:

bit.ly/CRA-deploy

在这一点上,任务持续了大约。 20 秒,然后它在 CPU 负载低于 1% 的情况下挂起 3 分钟并继续:
BUILD SUCCESSFUL in 3m 18s
2 actionable tasks: 1 executed, 1 up-to-date

奇怪的是,在另一台 Win10 机器上的类似项目上运行相同的配置会导致干净运行无卡住。

还有任务:
task "npm-install"( type:NpmTask ) {
args = [ 'install' ]
}
task "npm-set-proxy"( type:NpmTask ) {
args = [ 'config', 'set', 'https-proxy', 'http://www.www.www:80/' ]
}

显示相同的 3 分钟行为。

第二个配置看起来像:
apply plugin: 'com.bmuschko.tomcat'

ext.tomcatVersion = '9.0.30'

dependencies {
// some deps

tomcat "org.apache.tomcat.embed:tomcat-embed-core:$tomcatVersion",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:9.0.0.M6",
"org.apache.tomcat.embed:tomcat-embed-jasper:$tomcatVersion",
"org.apache.tomcat:tomcat-jdbc:$tomcatVersion",
"org.apache.tomcat:tomcat-dbcp:$tomcatVersion"
'org.postgresql:postgresql:42.2.12'
'log4j:log4j:1.2.17'
}

tomcat {
httpProtocol = 'org.apache.coyote.http11.Http11Nio2Protocol'
ajpProtocol = 'org.apache.coyote.ajp.AjpNio2Protocol'
httpPort = 8088
}

并在 Win10 中生成输出:
>gradlew.bat tomcatRun
> Configure project :
> Task :compileJava
> Task :processResources UP-TO-DATE
> Task :classes
> Task :tomcatRun

此时,它在 CPU 负载低于 18% 的情况下再次挂起约 3 分钟,然后继续:
LOG .......
LOG 2020-04-24 12:45:10,971 [Execution worker for ':'] INFO : - ActiveMq URL tcp://localhost:61620
Started Tomcat Server
The Server is running at http://localhost:8088/racy10
<=========----> 75% EXECUTING [4m 2s]

因此,无缘无故(从我的 POV)gradle 执行会在某些任务之后或之前挂起 3 分钟。

欢迎任何提示和想法!

TIA

最佳答案

检查%userprofile%\.gradle的权限目录,这是一个常见的罪魁祸首。在 Windows 10 上,这可能会受到 Windows Defender 的影响,但这只会减慢一点。直接从建议的命令行运行时测试它的行为方式,因为这将有助于缩小根本原因。而是使用 Exec task 也可能是一个选项,它将提供对 CLI 的完全控制;为 example .

关于java - 对于某些任务,Gradle 执行会卡住 3 分钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61406695/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com