Gradle fails when run in docker container

I am using Gradle and it works fine, except when I run it in a docker container. I use the jOOQ code generator. The generated source files are in build/generated-src/jooq, but the when building in the docker container, the compileJava task fails. I get compilation errors as the generated sources were not compiled, as an example:

/home/gradle/src/src/main/java/test/service/UserService.java:4: error: 
package test.database.mydb.tables.records does not exist
import test.database.mydb.tables.records.UserRecord;

In both occasions Gradle version 6.0.1 was used.

The Dockerfile:

FROM gradle:jdk11 as build-stage
COPY --chown=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle clean build

My build.gradle:

plugins {
    id 'java'
    id 'application'
    id 'nu.studer.jooq' version '3.0.3'
}

[...]

sourceSets.main.java.srcDir new File(buildDir, '/generated-src/jooq') // adding the generated sources of jooq folder to the main source set

jooq {
    version = '3.12.3'
    edition = 'OSS'
    database(sourceSets.main) {
        generator {
            database {
                [...]
            }
            target {
                packageName = 'me.mtte.code.ideahub.database'
                directory = new File(buildDir, '/generated-src/jooq') // the output directory
                clean = true
            }
        }
    }
}

Does anyone know why there is a difference between with and without docker container?

I also posted this question on stackoverflow: https://stackoverflow.com/questions/59590840/gradle-fails-when-run-in-docker-container