[英]Circular dependency when upgrading to Gradle 5
Our project worked until I tried to upgrade to Gradle 5. There the first thing it complained was that /
isn't a good character for multi-projects, eg bla/blub
isn't valid, so we changed this to bla:blub
(even though the error message said :
also isn't valid).我们的项目一直有效,直到我尝试升级到 Gradle 5。它抱怨的第一件事是
/
不是多项目的好角色,例如bla/blub
无效,所以我们将其更改为bla:blub
(即使错误消息说:
也无效)。 But now we apparently have a circular dependency which didn't exist before with Gradle 4:但是现在我们显然有了 Gradle 4 之前不存在的循环依赖:
Circular dependency between the following tasks:
:lap:server:classes
\--- :lap:server:compileJava
+--- :lap:server:compileKotlin
| \--- :lap:server:jar
| +--- :lap:server:classes (*)
| +--- :lap:server:compileKotlin (*)
| \--- :lap:server:inspectClassesForKotlinIC
| \--- :lap:server:classes (*)
\--- :lap:server:jar (*)
Why could this be?为什么会这样?
The problem was indeed with the :
notation in our settings.gradle
.问题确实出在我们的
settings.gradle
的:
符号上。 Now that I've changed all the nested projects to -
the problem is resolved.现在我已将所有嵌套项目更改为
-
问题已解决。
More concretely, before we had something like:更具体地说,在我们有类似的东西之前:
include 'common/server',
'someproject/server',
'someproject/common',
'someproject/search',
...
which worked with gradle 4.与gradle 4一起使用。
Then in Gradle 5 I've changed it to然后在 Gradle 5 中,我将其更改为
include 'common:server',
'someproject:server',
'someproject:common',
'someproject:search',
...
which caused the issue, presumably because someproject:common
depended on common:server
or something of the likes.这导致了这个问题,大概是因为
someproject:common
依赖于common:server
或类似的东西。
Now that I've changed it to现在我已经把它改成
include 'common-server'
project(':common-server').projectDir = file('common/server')
include 'someproject-server'
project(':someproject-server').projectDir = file('someproject/server')
include 'someproject-common'
project(':someproject-common').projectDir = file('someproject/common')
everything works like a charm.一切都像一个魅力。 By the way, the error with the circular dependency is also reproducible in Gradle 4, it's just that there we still had the
/
notation.顺便说一下,循环依赖的错误在 Gradle 4 中也是可以重现的,只是我们仍然有
/
符号。
For those of you who stumble on this question.对于那些偶然发现这个问题的人。
see : https://github.com/gradle/gradle/issues/847见: https : //github.com/gradle/gradle/issues/847
in a multi project setup, a duplicate "shortname" will throw in a monkey wrench:在多项目设置中,重复的“短名称”将插入活动扳手:
from the url above:从上面的网址:
myApp
- client
- common
- server
- common
Even though it should be 2 distinct entries, the duplicate (shortname) of "common" is the issue/bug.即使它应该是 2 个不同的条目,“common”的重复(简称)是问题/错误。
I ended up doing this: (my code is different names of course) (but the idea is)我最终这样做了:(我的代码当然是不同的名称)(但想法是)
myApp
- client
- clientcommon
- server
- servercommon
to disambiguate.消除歧义。
The url has some other ideas.该网址有一些其他想法。
What I saw in my code was, the built jars looked something like this:我在代码中看到的是,构建的 jars 看起来像这样:
common-1.0-SNAPSHOT.jar common-1.0-SNAPSHOT.jar
So that was what clued me in to "ahhh, maybe I have ambiguous issue with the shortname".所以这就是让我知道“啊,也许我对短名称有歧义的问题”的线索。 And finally found that github-gradle link.
终于找到了github-gradle这个链接。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.