包括本地jar作为api依赖项的Gradle库未显示在使用者的类路径中 [英] Gradle library including local jar as api dependency doesn't show up in consumer's classpath

查看:70
本文介绍了包括本地jar作为api依赖项的Gradle库未显示在使用者的类路径中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的gradle Java库项目中,我依赖于本地jar文件(工件不会在任何地方发布).依赖项配置如下:

In my gradle java library project, I have a dependency on a local jar file (the artifact is not published anywhere). The dependencies configuration looks like:

dependencies {
    api fileTree(dir: '3rdparty', include: '*.jar')
}

当我将库发布到maven local,然后将其从另一个项目中拉入时,即使3rdparty文件夹中的jar中的符号被列为api依赖项,也无法在类路径中使用.这仅仅是在库模块中直接使用jar文件之类的限制吗?

When I publish my library to maven local, and then pull it in from another project, the symbols from the jar in the 3rdparty folder aren't available on the classpath, even though it's listed as an api dependency. Is this just a limitation of using jar files directly within library modules or something?

推荐答案

这是对文件依赖项的众所周知的限制.Gradle文档对此很清楚

This is a well known limitation on File Dependencies. The Gradle documentation is clear on that

文件依赖项未包含在项目的已发布依赖项描述符中.但是,文件依赖关系包含在同一构建中的可传递项目依赖关系中.这意味着它们不能在当前内部版本之外使用,但可以在同一内部版本中使用.

File dependencies are not included in the published dependency descriptor for your project. However, file dependencies are included in transitive project dependencies within the same build. This means they cannot be used outside the current build, but they can be used within the same build.

原因很简单,与二进制存储库中托管的工件相比,其他项目无法从外部解决这些依赖关系.在声明依赖项用户指南中了解有关此主题的更多信息.

The reason is simply that those dependencies are not externally resolvable by other projects in contrast to artifacts hosted in a binary repository. Read more about this topic in the Declaring Dependencies userguide.

这篇关于包括本地jar作为api依赖项的Gradle库未显示在使用者的类路径中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆