Gradle withSourcesJar 作为库不起作用

发布于 2025-01-10 08:15:29 字数 651 浏览 2 评论 0原文

我当前有一个 Gradle Java 11 项目,我打算将其用作一个库,为其他应用程序提供一组通用功能。

我正在使用 Gradle 函数:

java{
    withSourcesJar()
}

构建包含源代码和 JavaDoc 的 .jar 。但是,当我将该 .jar 导入另一个应用程序(通过 Gradle 实现)时,.jar 库中的所有非 java SDK 依赖项都会失败,并显示以下样式的消息:

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

即使所有必需的依赖项都已经存在在主机应用程序中实现(也通过 Gradle)。

让我更困惑的部分是,如果我构建库 jar,作为一个简单的普通 .jar(意思是源代码,但没有 Javadoc),该库在其他应用程序中实现时可以顺利运行,只会失败当我尝试将其构建为 withSourcesJar() 时。

因此,任何可以帮助我了解我在 withSourcesJar() 中所做的事情或我应该添加哪些额外配置的帮助,将不胜感激。

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文