5

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

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

此时它再次挂起大约 3 分钟,CPU 负载低于 18%,然后继续:

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

4

1 回答 1

0

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

于 2020-05-03T03:40:46.207 回答