version-matchers | Apache Ivy™ Documentation

# version-matchers Tag: version-matchers [since 1.4] Defines a list of version matchers. The child tag used for the version matcher must be equal to a name of a report outputter type (added with the `typedef` tag). A version matcher is used to evaluate if a dependency version constraint matches a dependency version. ## Attributes
Attribute | Description | Required
--- | --- | ---
usedefaults | when set to true, includes the built-in version matchers (Latest, Sub Revision, and Version Ranger Matcher). Exact Revision Matcher is always included | No, defaults to false
## Child elements
Element | Description | Cardinality
--- | --- | ---
any version matcher | adds a version matcher to the list of available ones | 0..n
## Built-in Version Matchers ### Exact Revision Matcher A matcher that matches a dependency revision id to the module revision id using simple string equality. ### Sub Revision Matcher A matcher that matches all revisions starting with a specific prefix. The syntax is: `[prefix]+`
Revision | Matches
--- | ---
1.0.+ | all revisions starting with '1.0.', like 1.0.1, 1.0.5, 1.0.a
1.1+ | all revisions starting with '1.1', like 1.1, 1.1.5, but also 1.10, 1.11
### Latest (Status) Matcher A matcher that matches versions based on their status. The predefined statuses in Ivy are `release`, `milestone` and `integration`. It’s possible to define your own statuses, see statuses for more details.
Revision | Matches
--- | ---
latest.integration | all versions
latest.milestone | all modules having at least 'milestone' as status
latest.release | all modules having at least 'release' as status
latest.[any status] | all modules having at least the specified status
### Version Range Matcher Range types are exhaustively listed by example in the table below.
Revision | Matches
--- | ---
[1.0,2.0] | all versions greater or equal to 1.0 and lower or equal to 2.0
[1.0,2.0[ | all versions greater or equal to 1.0 and lower than 2.0
]1.0,2.0] | all versions greater than 1.0 and lower or equal to 2.0
]1.0,2.0[ | all versions greater than 1.0 and lower than 2.0
[1.0,) | all versions greater or equal to 1.0
]1.0,) | all versions greater than 1.0
(,2.0] | all versions lower or equal to 2.0
(,2.0[ | all versions lower than 2.0
### Version Pattern Matcher The version pattern matcher allows for more flexibility in pattern matching at the cost of adding a matcher declaration in Ivy settings. A simple example is given below. #### Settings.xml
    <pattern-vm>
      <match revision="foo" pattern="${major}\.${minor}\.\d+" args="major, minor" matcher="regexp"/>
    </pattern-vm>
#### Ivy.xml
    <dependency org="acme" name="tool" rev="foo(1, 3)"/>
The version pattern matcher may contain more than one match element. The matcher will attempt to match a dependency revision against each match in sequence, checking the revision tag (e.g. foo(..)) and then the pattern. Matcher types may be one of "regexp", "exact", "glob", or "exactOrRegexp". Glob pattern matching requires Apache ORO 2.0.8 or higher to be on the classpath. ### Maven timestamped snapshot version matcher [since 2.5] Maven has the notion of timestamped snapshots, which essentially are snapshot versions of a particular Maven artifact, but have a specific timestamp associated with them so that the snapshot revision (which by nature are changing over time), can be traced back to the exact artifacts. Maven allows other artifacts to depend on such timestamped snapshots. Ivy too allows such timestamped dependencies to be part of the module’s dependencies. For such dependencies to be properly parsed and resolved, a `maven-tsnap-vm` version matcher needs to be configured in the Ivy settings and ibiblio resolver must be one of the resolvers that are used for dependency resolution.
Note | Maven has a specific syntax for timestamped snapshot versions and only such versions are understood by Ivy.
Configuring the `maven-tsnap-vm` can be done as follows in the Ivy settings file:
    <ivysettings>
        <version-matchers ...>
            <maven-tsnap-vm/>
        </version-matchers>
        ...
An example timestamped snapshot dependency in an Ivy module would look like:
    <ivy-module version="2.4">
        <info organisation="org.apache.ivy"
              module="maven-snapshot-deps-test"
              revision="1.2.3"/>
        <dependencies>

            <dependency org="org.apache.ivy.maven-snapshot-test" name="foo-bar" rev="5.6.7-20170911.130943-1"/>
        </dependencies>
    </ivy-module>
Notice the `5.6.7-20170911.130943-1` revision on the `foo-bar` dependency - that represents a timestamped snapshot. For this Ivy module to be resolved correctly, the Ivy settings file should be both backed by the `maven-tsnap-vm` version matcher and a `m2compatible` `ibiblio` resolver, so the settings file would typically look like:
    <ivysettings>
        <settings defaultResolver="m2"/>
        <caches defaultCacheDir="${user.home}/.ivy/cache/"/>
        <version-matchers usedefaults="true">
            <maven-tsnap-vm/>
        </version-matchers>

        <resolvers>
            <ibiblio name="m2" m2compatible="true" useMavenMetadata="true" root="file://${user.home}/.m2"/>
        </resolvers>

    </ivysettings>