-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e6de8cf
commit 6207da1
Showing
2 changed files
with
45 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import com.typesafe.tools.mima.plugin.MimaKeys._ | ||
import com.typesafe.tools.mima.plugin.MimaPlugin | ||
import sbt.{AutoPlugin, CrossVersion} | ||
import sbt.Keys._ | ||
import sbt._ | ||
|
||
import scala.collection.immutable | ||
|
||
object Mima extends AutoPlugin { | ||
override def requires = MimaPlugin | ||
|
||
override def trigger = allRequirements | ||
|
||
private def expandVersions(major: Long, minor: Long, patches: immutable.Seq[Int]): immutable.Seq[String] = | ||
patches.map(patch => s"$major.$minor.$patch") | ||
private def previousArtifacts(projectName: String, organization: String, version: String): Set[sbt.ModuleID] = { | ||
val Some((major, minor)) = CrossVersion.partialVersion(version) | ||
val currentPatchVersion = version.split("\\.").last | ||
val stripRegex = """(\d+)(.*)""".r | ||
|
||
val currentPatchVersionStripped = currentPatchVersion match { | ||
case stripRegex(v, _) => v.toInt | ||
} | ||
|
||
if (currentPatchVersionStripped == 0) | ||
Set(organization %% projectName % s"$major.$minor.0") | ||
else | ||
expandVersions(major, minor, 0 until currentPatchVersionStripped).map(v => organization %% projectName % v).toSet | ||
} | ||
|
||
override lazy val projectSettings = Seq( | ||
mimaReportSignatureProblems := true, | ||
mimaPreviousArtifacts := previousArtifacts(name.value, organization.value, version.value) | ||
) | ||
} |