Gradle library including local jar as api dependency doesn't show up in consumer's classpath

元气小坏坏 提交于 2021-02-11 15:23:55

问题


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')
}

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?


回答1:


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.



来源:https://stackoverflow.com/questions/59534753/gradle-library-including-local-jar-as-api-dependency-doesnt-show-up-in-consumer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!