Javadoc sources and generated source

I’m not sure why something as simple as generating javadoc is causing me such problems. What’s more concerning is that this is actually an issue I first reported 6 years ago[1] and still have not found a solution. Its really a simple problem - I’d like to exclude generated java sources from javadoc generation. The generated sources are generated into a dedicated directory - I try to exclude on that directory name but this does not work. Considering I have another exclude based on a package name pattern that actually does work, I’d have to assume that the exclusions are relative name (package) based rather than directory name based. I went back and re-tried all the suggestions from Peter from that old thread just to verify that they still do not work.

So what is it I need to do to get these generated source files excluded from javadoc processing?

[1] Excluding generated source from javadoc

Here is the task config fragment using exlude:

javadoc {
    exclude( "**/internal/**" )
    exclude( "**/generated-src/**" )
    ...
}

The exclusion on “internal” works - “internal” is actually part of the package name. The exclusion “generated-src” does not work - it is part of the directory path where generated sources are generated in to.

I’ve also tried to fiddle with javadoc.sources to exclude java files whose absolute path is under "**/generated-src/**" which unfortunately also does not work although leads to errors (see linked old discussion).