简体   繁体   English

新的 Gradle 依赖项未添加到项目和外部依赖项(VSCode)

[英]New Gradle dependency not added to project and external dependencies (VSCode)

I've been having this issue on and off for the past few weeks after beginning to learn how to use Gradle.在开始学习如何使用 Gradle 后的过去几周里,我一直遇到这个问题。

I added the dependency to my build.gradle file我将依赖项添加到我的 build.gradle 文件中

compile group: 'org.apache.xmlgraphics', name: 'batik-all', version: '1.12', ext: 'pom'

I used VSCode's command palette to "refresh", cleaned the server workspace and ran gradle build but the new dependency does not show up in my "Project and External Dependencies" and I cannot import org.apache.batik.*我使用 VSCode 的命令面板“刷新”,清理服务器工作区并运行 gradle 构建,但新的依赖项没有显示在我的“项目和外部依赖项”中,我无法导入org.apache.batik.*

Hoping to find a fix for this in VSCode as I have seen some other IDE specific fixes.希望在 VSCode 中找到解决此问题的方法,因为我已经看到了一些其他 IDE 特定修复。

So the issue was that in the map notation you were specifying the ext: 'pom' part.所以问题是在 map 表示法中,您指定了ext: 'pom'部分。 This effectively told Gradle to only import the POM file and not treat the dependency as a regular one.这有效地告诉 Gradle导入 POM 文件而不将依赖项视为常规文件。

When you moved to the different notation, you did not keep that pom element in the coordinates and so you got the right behaviour.当您使用不同的符号时,您没有将pom元素保留在坐标中,因此您得到了正确的行为。

Note: compile has been replaced by implementation for a while now and is even deprecated in Gradle 6.x.注意: compile已经被implementation取代了一段时间,甚至在 Gradle 6.x 中被弃用。 Have a look at the documentation for more information on this.查看文档以获取更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM