This message was deleted.
# dependency-management
s
This message was deleted.
r
First, let's review the documentation:
The strings
rc
,
snapshot
,
final
,
ga
,
release
and
sp
are considered higher than any other string part (sorted in this order):
1.0-zeta
<
1.0-rc
<
1.0-snapshot
<
1.0-final
<
1.0-ga
<
1.0-release
<
1.0-sp
<
1.0
.
Now compare these two dependency resolution results:
Copy code
resolverTest
+--- brazil:FooLib:1.0-release
+--- brazil:FooLib:1.0-debug -> 1.0-release
\--- brazil:FooLib:1.0-releaseProguarded -> 1.0-release
Copy code
resolverTest
+--- brazil:FooLib:{prefer 1.0-release} -> 1.0-releaseProguarded
+--- brazil:FooLib:{prefer 1.0-debug} -> 1.0-releaseProguarded
\--- brazil:FooLib:{prefer 1.0-releaseProguarded} -> 1.0-releaseProguarded
When there are only
prefer
constraints, does Gradle pick the highest preferred version? Or does it arbitrarily pick a single constraint to use?
v
Interesting. I would have expected release to be taken. Maybe we are both wrong, or you found a bug.
r
Oh, here it is:
prefer
This is a very soft version declaration. It applies only if there is no stronger non dynamic opinion on a version for the module. This term does not support dynamic versions.
Definition can complement
strictly
or
require
.
When defined, this overrides any previous
prefer
declaration and clears previous
reject
.
Last-write-wins? Clears previous
reject
? Kind of unsettling
v
I think it just means within one rich version. If you for example have
Copy code
version {
    reject("1")
    reject("2")
    prefer("3")
    prefer("4")
    reject("5")
    reject("6")
}
Then the
prefer("4")
will override the
prefer("3")
and for whatever reason clear the rejects for 1 and 2. So you end up with prefer 4 and reject 5 and 6.
So I don't think that description covers the behaviour you showed
r
In other words, you think the "replacement" behavior is scoped to a single
Dependency
instance, not to an entire
Configuration
v
Exactly, everything else also would not make any sense.
The description should only describe the behavior within one rich version as far as I remember
Though I might of course be wrong 🙂
s
This looks buggy to me. It looks to me that we're comparing the preferred versions lexicographically and picking the "highest" version. If you had
1.0-zzz
, you'd get that version instead. Oddly, if you use a dynamic version anywhere in the graph (
:brazil:FooLib:+
), you get the
1.0-release
version instead. If instead of using a rich version, you use those same versions with the simple GAV notation, you also get
1.0-release
, so I suspect there's a bug when there are no stronger constraints and we have to choose between the preferred versions.
Björn is right that the javadoc is only referring to that particular dependency, not the graph as a whole
r
Oddly, if you use a dynamic version anywhere in the graph (
:brazil:FooLib:+
), you get the
1.0-release
version instead.
That makes sense, since that resolves to the equivalent of
require("1.0-release")
, right? And
1.0-release
is ranked higher than almost any other qualifier. It's subject to those special rules
s
ah, yeah, I guess it's looking at all the available versions and resolving to the latest via a different path. I thought that was somehow influencing the comparisons between preferred versions
r
It also looked to me like it was applying ASCIIbetical sorting rules and not the full Gradle version ordering rules with special cased qualifiers etc
s
I found something that looks promising. I'm going to get another set of eyes and run it through CI before I spend more time on it
There was a point where if we only had preferred versions, we just sorted them reverse-lexicographically and returned the first one. It doesn't look intentional
👌 1