Gradle vaadinClean fails if project dependency doesn't have a jar

I have a gradle project with multiple subprojects. One of them is a vaadin 24 application and another is just a commons library that is included via:

implementation project(':common')

When I execute the gradle task “vaadinClean” on the vaadin subproject, it succedes when the jar of the common project exists, but fails if it doesn’t with the following error:

* What went wrong:
Execution failed for task ':event-anwendung:vaadinClean'.
> /[...]/common/build/libs/common-0.5.2530-1327.jar doesn't exist

This happens eg. when I execute gradle clean on the common project first. If i remove the dependency from the vaadin project, “vaadinClean” also succedes. Any suggestion why this happens?

A possible reason for this failure:

  • vaadinClean has dependsOn("clean"). When you run vaadinClean, Gradle first runs clean for the event-anwendung (Vaadin) subproject.
  • However, vaadinClean might also be resolving dependencies, including common, and expects the JAR file of common to exist.
  • If common was already cleaned earlier (e.g., gradle clean common), its JAR file is missing, causing vaadinClean to fail because it cannot find common/build/libs/common-*.jar.

I couldn’t find anything else than “dependsOn(“clean”)” in vaadinClean that might cause this failure, other codes just delete the various frontend files.

A workaround may be to build commons before vaadinClean:
./gradlew common:build event-anwendung:vaadinClean

or by telling Gradle to ignore and continue:
./gradlew vaadinClean --continue

If you make a reproducible example, we can take a look deeper.