How do I launch a JavaExec task relinquishing all locks to script cache?

I am running into ‘Timeout waiting to lock buildscript class cache for build file’ error very frequently. Here is my workflow which leads to this:

  1. My gradle project has many sub-projects. 2) In one sub-project (say, ‘ONE-PRJ’) I launch a task which never ends (say, like an embedded Jetty server) using the ‘JavaExec’ task 3) One of my other sub-projects (say, ‘TWO-PRJ’) depends on ‘ONE-PRJ’ 4) I fetch changes from my remote git repository; one my colleague have changed the build script for ‘ONE-PRJ’ 5) I try to build ‘TWO-PRJ’. This tries to build ‘ONE-PRJ’, and can’t get the an exclusive lock to the script cache (which seems to be keyed by canonical path of the build script)

I have a reproducible test case at https://github.com/binil/gradle-long-running-task-problem

How do I launch a java program with ‘JavaExec’ relinquishing all locks?

This amounts to running the same build twice at the same time, which to my knowledge isn’t supported. A potential solution is to launch the application asynchronously so that the build can end. ‘Exec’ and ‘JavaExec’ cannot currently do this, but you could try ‘ant.exec’ or ‘ant.java’ with ‘spawn=true’.

@Peter Niederwieser: the long-running processes we launch log to console constantly, so it would be undesirable to have the build end and those logs show up haphazardly on the terminal. We were looking to provide a user-experience similar to what Jetty plugin provides - an ad hoc long running process launched from the terminal. How does Jetty plugin handle this case? Are they also susceptible to the same issues?