What does highest means when gradle handle dependency conflict?

Viewed 43

I know that gradle choose the highest version when solve dependency conflict by default. But what's the definition of highest.

I have a dependency conflict problem and I run dependencies task finding that this two version of the same dependency conflicts: AD-106715-1-SNAPSHOT and 1.0.36. Gradle choose the 1.0.36 version.

com.mycompany.service:ad-biz-jasper-contract:AD-106715-1-SNAPSHOT -> 1.0.36

But why? Is 1.0.36 higher than AD-106715-1-SNAPSHOT? But lexicographically the later one is higher.
So I want to know how gradle define which version is higher.

1 Answers

The exact rules are described in the Gradle docs, but the short (and somewhat oversimplified) version is:

  1. split the version by .
  2. compare each part numerically except if:
    • only one of the parts are numerical, then the numerical part is considered higher
    • both parts are non-numerical, then sort them alphabetically, case-sensitive

Then there's a couple more rules with special cases for dev, rc, final, ... and what to do when one one string has more parts than the others and the first ones don't give a specific order, but those don't apply in this case.

Related