Circular dependency when upgrading to Gradle 5

Viewed 337

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, e.g. bla/blub isn't valid, so we changed this to bla:blub (even though the error message said : also isn't valid). But now we apparently have a circular dependency which didn't exist before with 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?

2 Answers

The problem was indeed with the : notation in our 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.

Then in Gradle 5 I've changed it to

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.

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.

For those of you who stumble on this question.

see : 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.

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:

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.

Related