Reputation: 30528
I have a project where I apply the Gradle application
plugin. My problem is that it doesn't terminate even if the underlying process terminates: if I run this:
gradle run
with a main
which only contains a System.exit(0);
the program terminates but Gradle
doesn't. How do I force the Gradle process to terminate when the underlying Java program terminates?
Edit: I Know I can call gradle --stop
but that would require another process and it is not an option.
Upvotes: 0
Views: 940
Reputation: 294
kill the java process manually from cli. linux using killall java
, windows using taskkill /f /im java.exe
for an example my script.cmd
@echo off
taskkill /f /im java.exe
call gradlew :app:assembleAarch64Release --no-daemon -Dorg.gradle.jvmargs="-Xmx1g -Xms300m"
taskkill /f /im java.exe
call gradlew :app:assembleArmRelease --no-daemon -Dorg.gradle.jvmargs="-Xmx1g -Xms300m"
taskkill /f /im java.exe
call gradlew :app:assembleX86Release --no-daemon -Dorg.gradle.jvmargs="-Xmx1g -Xms300m"
taskkill /f /im java.exe
call gradlew :app:assembleX86_64Release --no-daemon -Dorg.gradle.jvmargs="-Xmx1400m -Xms300m"
taskkill /f /im java.exe
it will kill java each finished task. to keep my pc performance
Upvotes: 0
Reputation: 3634
gradle run
terminates when your application terminates. However, if you use gradle daemon (enabled by default in later versions), the daemon still prevails.
The easiest solution is to pass --no-daemon
to the gradle CLI. You can also configure it in the properties.
Upvotes: 1