5

I have 2 relatively simple Gradle 6.1.1 configs, one is using https://plugins.gradle.org/plugin/com.github.node-gradle.node to build a react app, and the other one is based on https://plugins.gradle.org/plugin/com.bmuschko.tomcat and runs a simple wicket app in embedded tomcat.

The 1st config for npm task is:

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' ]
}

and produces the following output in 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

at this point the tasks lasted approx. 20 seconds, then it hangs for 3 min with CPU-load below 1% and continues:

BUILD SUCCESSFUL in 3m 18s
2 actionable tasks: 1 executed, 1 up-to-date

The strange thing is that running the same config on similar project on another Win10 machine results in clean run w/o freezes.

Also the tasks:

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

show the same 3-extra-minutes behavior.

The 2nd config looks like:

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
}

and produces the output in Win10:

>gradlew.bat tomcatRun
> Configure project :
> Task :compileJava
> Task :processResources UP-TO-DATE
> Task :classes
> Task :tomcatRun

at this point it hangs for again for around 3 mins with CPU-load below 18% and then continues:

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]

So for no reason (from my POV) the gradle excecution hangs for 3 mins either after or before certain tasks.

Any hints and ideas are welcome!

TIA

injecteer
  • 20,038
  • 4
  • 45
  • 89

1 Answers1

0

Check the permissions of %userprofile%\.gradle directory, which is a common culprit. On Windows 10 this might be affected by Windows Defender, but this should only slow down a little. Testing how it behaves when running it from directly the command-line suggested, because this would help to narrow the down root cause. Instead using an Exec task might also be an option, which would provide full control over the CLI; for example.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
  • I started with moowork plugin, but had to switch to it's fork. In my attempts it shown the same +3 mins behaviour – injecteer May 03 '20 at 09:38
  • And when you run it directly form the command line? The Tomcat project or server might be the cause, in case different Gradle plugins show the same behavior... or the user profile (which varies, depending on which user runs it). Or even tried `gradlew :tomcatRun`? This runs only that task; Ever ran Tomcat from CLI? Try to substitute with `Exec` (alike my example shows for `node`) and it should not get stuck... this may differ in between versions; another version of Tomcat might eventually not stall. – Martin Zeitler May 03 '20 at 20:50
  • In case it's not the Tomcat server itself; you could file an [issue](https://github.com/bmuschko/gradle-tomcat-plugin/issues) there... I mean, if it's not the NPM plugin, then it might rather be the Tomcat plugin or Tomcat server. Since I cannot reproduce it; I can only tell how to narrow down the possibilities. – Martin Zeitler May 03 '20 at 20:54