'Gradle withSourcesJar as library not working

I have a current Gradle, Java 11, project that I intent to use as a library with a set of general purpose functions for another apps.

I'm using the Gradle function:

java{
    withSourcesJar()
}

To build a .jar with the source and JavaDoc included. However when I import that .jar into another app (via Gradle implementation) all the non java SDK dependencies in the .jar library fails with a message of the style:

Package 'x' is declared in module 'y', but module 'z' does not read it

Even though that all the required dependencies are already implemented (via Gradle as well) in the host app.

The part that puzzle me more, is that if I build the library jar, as a simple plain .jar(meaning source code but no Javadoc) the library works smoothly when implemented in other apps, it only fails when I try to build it as a withSourcesJar().

So any help that could point me on what I doing wring in the withSourcesJar() or what extra configuration should I add, would be appreciated.

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source