So imagine I have the following versions for mylib: 1.2.3, 1.2.4, 1.2.5-17.4, 1.3.0-17.4, 1.3.0
if I pull now `mylib` with `latestRel(17.4)` it will return `1.3.0-17.4`. The question is only why does it work? I have just defined a regular expression to match this pattern but I do not say anywhere that it should return me the latest one.
In addition to what I explained in my previous comment, Ivy has the concept of "listing versions from a repository" for a particular dependency if the revision being asked for is a "dynamic" revision. What that means is, in this example:
java -jar ivy.jar -settings ivysettings.xml -dependency com.acme mylib "latestRel(17.4)"
where your dependency is of the form:
<dependency org="com.acme" name="mylib" rev="latestRel(17.4)"/>
when the resolution happens, the Ivy resolver implementation checks if the asked revision latestRel(17.4) is a "dynamic revision". Revisions that are backed by a pattern version matcher (like in your case) are considered dynamic revisions. So Ivy resolver implementation, then goes and asks the repository, which is identified for this dependency, to "list the versions" known to that repository, for the dependency module (com.acme:mylib in this case). The repository, in this example, returns the versions 1.2.3, 1.2.4, 1.2.5-17.4, 1.3.0-17.4, 1.3.0.
The Ivy resolution further has a concept called, "latest strategies", which gets used for dynamic version dependencies, when more than one version is available. When no latest strategy is explicitly configured, Ivy uses the default "latest-revision" strategy. The configured (or defaulted) latest strategy is then used to sort the list of versions that were returned by the repository, in the previous step. So in your example, it's going to sort those versions (1.2.3, 1.2.4, 1.2.5-17.4, 1.3.0-17.4, 1.3.0) into a list. This sorted list is then iterated over, by the Ivy resolver implementation and sent to the applicable version matcher (in this case your pattern matcher). The first version that is "accepted" by the matcher is considered as the resolved version for that dependency. So in this example, your pattern matcher gets the 1.3.0-17.4 version befor it gets the 1.2.5-17.4, for evaluation, which it evaluates as "acceptable" (i.e. the matches the pattern of your interest) and hence the resolver ends up using this version.