Gradle keeps waiting for JavaExec task to Complete

Gradle keeps waiting for JavaExec task to Complete. But I want gradle to move to other task and let the JavaExec Application to run in background till build is over .
In Ant we simply acheived this by <parallel><daemons> <java fork="true"> <daemons/><parallel/>

But in gradle not getting a Simpler solution and Worker API seems complex. JavaExec already triggers the app in fork then why should i use Worker API ? Only requirement here is to let the JavaExec execute and dont wait for it

Please help if any inputs

My Requirement is like below: Both JavaExec App1 and App2 should stay running while my junit tests will run . Once JunitTest completes then App1 and App2 to shut and build to complete.

 task.register("Runner"){
    dependsOn(['CompiletestClasses','RunJavaApplication1','RunJavaApplication2','RunJunitTests'])
    }

tasks.register('RunJavaApplication1', JavaExec){}
tasks.register('RunJavaApplication2', JavaExec){}

  • I tried using ExecutorService es = Executors.newSingleThreadExecutor() es.execute({ project.javaexec { It runs the Java App in background as expected but the Application does not gets closed after the gradle buid finishes

    – 




  • Make sure next task is no marked to depend on JavaExec.

    – 

  • @LMC Even if we dont put dependency Gradle runs one task at a time so it will stay on the JavaExec task only and not move further …… Tried –parallel and org.gradle.parallel=true in gradle.properties both didnot work

    – 




Leave a Comment