Multiproject build, ClassNotFoundException only after cleaning the external 'dependency' project

My project structure:

main
----+ folders
----+ build.gradle
----+ settings.gradle
dependency
----+ folders
----+ jooq
----+ build.gradle
----+ settings.gradle

‘dependency’ is only needed in the build phase. It contains a .jar which is generated before ‘main’ “asks for it”. Performing a clean on ‘dependency’ before a clean build for ‘main’ throws this error:

Execution failed for task ':test-service:generateMysqlJooqSchemaSource'.
> java.lang.ClassNotFoundException: ... .Generator

A simple gradle build under ‘main’ finishes without any errors

I believe gradle might have some specific cache loaded which prevents it from detecting something.jar preventing it from accessing the class.

(Sidenote: ‘main’ and ‘dependency’ are named differently)

Cheers!