sbt-version-policy
sbt-version-policy:
- configures sbt-mima to guarantee that your library follows the recommended versioning scheme,
- ensures that none of your dependencies are bumped or removed in an incompatible way.
How to use
Add to your project/plugins.sbt:
addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "1.0.0-RC1")
sbt-version-policy depends on sbt-mima, so that you don't need to explicitly depend on it.
versionPolicyCheck
The versionPolicyCheck task:
- runs
mimaReportBinaryIssues, - along with
versionPolicyReportDependencyIssues
versionPolicyReportDependencyIssues itself checks for
- removed dependencies, or
- dependencies bumped in an incompatible way,
and fails if any of these checks fails.
Automatic previous version calculation
sbt-version-policy automatically sets mimaPreviousArtifacts, depending on the current value of version, kind of like sbt-mima-version-check does. The previously compatible version is computed from version the following way:
- drop any "metadata part" (anything after a
+, including the+itself)- if the resulting version contains only zeros (like
0.0.0), leavemimaPreviousArtifactsempty, - else if the resulting version does not contain a qualifier (see below), it is used in
mimaPreviousArtifacts.
- if the resulting version contains only zeros (like
- else, drop the qualifier part, that is any suffix like
-RC1or-M2or-alphaor-SNAPSHOT- if the resulting version ends with
.0,mimaPreviousArtifactsis left empty - else, the last numerical part of this version is decreased by one, and used in
mimaPreviousArtifacts.
- if the resulting version ends with
versionPolicyPreviousArtifacts
versionPolicyReportDependencyIssues compares the dependencies of versionPolicyPreviousArtifacts to the current ones.
By default, versionPolicyPreviousArtifacts relies on mimaPreviousArtifacts from sbt-mima, so that only setting / changing mimaPreviousArtifacts is enough for both sbt-mima and sbt-version-policy.
Dependency compatibility adjustments
Set versionPolicyDependencyRules to specify whether library dependency upgrades are compatible or not. For instance:
versionPolicyDependencyRules += "org.scala-lang" % "scala-compiler" % "strict"
The following compatility types are available:
early-semver: assumes the matched modules follow a variant of Semantic Versioning that enforces compatibility within 0.1.z,semver-spec: assumes the matched modules follow semantic versioning,pvp: assumes the matched modules follow package versioning policy (quite common in Scala),always: assumes all versions of the matched modules are compatible with each other,strict: requires exact matches between the wanted and the selected versions of the matched modules.
If no rule for a module is found in versionPolicyDependencyRules, versionPolicyDefaultReconciliation is used as a compatibility type. Its default value is VersionCompatibility.PackVer (package versioning policy).
Acknowledgments
sbt-version-policy is funded by the Scala Center.
