18.5. Controlling Which Version of a Managed Dependency Is Used
Problem
You want to make sure you always have the desired version of a managed dependency, including the latest integration release, milestone release, or other versions.
Solution
The revision
field in the
libraryDependencies
setting isn’t
limited to specifying a single, fixed version. According to the Apache
Ivy documentation, you can specify terms such as latest.integration
, latest.milestone
, and other terms.
As one example of this flexibility, rather than specifying version
1.8
of a foobar
module, as shown here:
libraryDependencies += "org.foobar" %% "foobar" % "1.8"
you can request the latest.integration
version like this:
libraryDependencies += "org.foobar" %% "foobar" % "latest.integration"
The module developer will often tell you what versions are available or should be used, and Ivy lets you specify tags to control which version of the module will be downloaded and used. The Ivy “dependency” documentation states that the following tags can be used:
latest.integration
latest.[any status]
, such aslatest.milestone
You can end the revision with a
+
character. This selects the latest subrevision of the dependency module. For instance, if the dependency module exists in revisions1.0.3
,1.0.7
, and1.1.2
, specifying1.0.+
as your dependency will result in1.0.7
being selected.You can use “version ranges,” as shown in the following examples:
[1.0,2.0] matches all versions greater or equal to 1.0 and lower or equal to 2.0 [1.0,2.0[ ...
Get Scala Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.