Sometimes, possibly due to a race condition, the deployDocs task fails in the following way:

rm: cannot remove ‘/var/www/domains/spring.io/docs/htdocs/autorepo/docs/spring-security/6.3.2-SNAPSHOT/api/org/springframework/security’: Directory not empty

Since the corresponding rm command uses -f and still fails, this may mean that another process is operating on that directory at the same time.

rsync may be a better option for achieving atomicity than removing the old directory, creating a new one, and moving the new contents into the new directory.