如何使用Gradle更新外部JAR文件,而不会破坏一切?

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

How to update external jar file without breaking everything with gradle?

问题

更新包含重大更改的外部 jar 文件时,代码在某些点可能会出现错误(这是正常的情况)。但我无法通过 gradle 构建项目,因此来自该 jar 文件的每个导入在我的 IDE(Intellij)中都显示为错误。

这实际上使得很难定位错误所在,因为来自该 jar 文件的所有导入都显示为“错误”,尽管所有这些类都在其中,因为构建失败意味着 gradle 根本不会导入该 jar 文件...

最终的结果是,我的 IDE 显示类似于以下内容(出于安全原因已删除包名):

如何使用Gradle更新外部JAR文件,而不会破坏一切?

所有这些 model.entity 类都在 jar 文件中,但是由于构建过程在代码中的第一个语法错误处停止,gradle 不会导入它们...

是否有任何方法可以解决这个问题?如何在不依赖 gradle 控制台内的错误消息的情况下重构大型代码库(可能会有很多错误消息)。

我想先导入该 jar 文件,然后再修复语法错误。也许有不同的 gradle 命令?我只是使用“clean build”。

英文:

When updating an external jar file which contains breaking changes, so the code at certain points will have errors (which happens and is fine), I am unable to build my project via gradle, thus EVERY import from the jar shows up in my IDE as an error (Intellij).

This makes it super hard to actually see where the errors are, since ALL imports from the jar, even though all those classes are in there show up as "errors", since build failure means gradle simply wont import the jar at all...

The end result is that my IDE shows things like this (removed package name for security reasons):

如何使用Gradle更新外部JAR文件,而不会破坏一切?

All of those model.entity classes ARE in the jar, but gradle wont import them because the build process stops at the first syntax error in the code...

Is there any way around this? How to refactor large code bases without relying on the error messages inside the gradle console (which there might be a LOT of).

I'd like to import the jar first THEN fix the syntax errors? Maybe a different gradle command? I'm simply using "clean build"

答案1

得分: 1

以下是翻译好的内容:

这里有两个方面。

  1. 成绩
  2. IDE(似乎是Intellij)- 导入gradle以创建项目。除非开启自动刷新,否则在gradle文件发生更改时需要手动重新导入(刷新按钮)。

在您的情况下,初始状态是gradle构建正常,Intellij正常工作。

您用“破坏性”更改替换了依赖项。

  1. gradle build - 由于代码尚未修复,将在编译阶段失败。

  2. IntelliJ - 仍然看不到新的依赖项。点击“重新导入”。

导入将始终成功,除非.gradle文件中存在错误。
导入后,IDE现在将反映新的依赖项。

英文:

There are 2 aspects here.

  1. grade
  2. IDE (appears to be Intellij) - imports the gradle to create project. unless on auto refresh, requires manual reimport (refresh button) when there are changes in gradle files

in your scenario, initial state is gradle build works, Intellij works fine

you replace the dependency with 'breaking' change.

  1. gradle build - will fail at compile stages as code is yet to the fixed

  2. IntelliJ - still is not seeing new dependency. click the re-import

The import will always succeed unless there are errors in .gradle files
After import IDE will now reflect new dependency

huangapple
  • 本文由 发表于 2020年9月10日 00:50:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/63816120.html
匿名

发表评论

匿名网友

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

确定