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

huangapple go评论149阅读模式
英文:

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.

I added the dependency to my build.gradle file

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.*

Hoping to find a fix for this in VSCode as I have seen some other IDE specific fixes.

英文:

I've been having this issue on and off for the past few weeks after beginning to learn how to use Gradle.

I added the dependency to my build.gradle file

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.*

Hoping to find a fix for this in VSCode as I have seen some other IDE specific fixes.

答案1

得分: 1

问题是在地图表示法中,您指定了ext: 'pom'部分。这实际上告诉Gradle仅导入POM文件,而不将依赖项视为常规依赖项。

当您切换到不同的表示法时,没有在坐标中保留pom元素,因此您得到了正确的行为。

注意:compile现在已经被implementation替代了,并且在Gradle 6.x中已经弃用。请查看文档了解更多信息。

英文:

So the issue was that in the map notation you were specifying the ext: 'pom' part. This effectively told Gradle to only import the POM file and not treat the dependency as a regular one.

When you moved to the different notation, you did not keep that pom element in the coordinates and so you got the right behaviour.

Note: compile has been replaced by implementation for a while now and is even deprecated in Gradle 6.x. Have a look at the documentation for more information on this.

huangapple
  • 本文由 发表于 2020年4月7日 04:01:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/61068001.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定