2023-01-08 17:13:31 +08:00
|
|
|
/*
|
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
|
* license agreements; and to You under the Apache License, version 2.0:
|
|
|
|
|
*
|
|
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
2023-06-22 14:19:26 +01:00
|
|
|
* This file is part of the Apache Pekko project, which was derived from Akka.
|
2023-01-08 17:13:31 +08:00
|
|
|
*/
|
|
|
|
|
|
2019-01-02 18:55:26 +08:00
|
|
|
/*
|
2022-02-04 12:36:44 +01:00
|
|
|
* Copyright (C) 2009-2022 Lightbend Inc. <https://www.lightbend.com>
|
2015-01-22 20:26:34 +02:00
|
|
|
*/
|
2018-03-13 23:45:55 +09:00
|
|
|
|
2019-04-19 08:54:25 +02:00
|
|
|
import scala.collection.immutable
|
2015-02-19 15:49:02 +01:00
|
|
|
import sbt._
|
2016-03-10 10:45:35 +02:00
|
|
|
import sbt.Keys._
|
|
|
|
|
import com.typesafe.tools.mima.plugin.MimaPlugin
|
|
|
|
|
import com.typesafe.tools.mima.plugin.MimaPlugin.autoImport._
|
2015-01-22 20:26:34 +02:00
|
|
|
|
|
|
|
|
object MiMa extends AutoPlugin {
|
|
|
|
|
|
2023-07-15 10:31:54 +01:00
|
|
|
private val latestPatchOf10 = 0
|
2017-07-27 13:33:14 +03:00
|
|
|
|
2016-03-10 10:45:35 +02:00
|
|
|
override def requires = MimaPlugin
|
2015-01-22 20:26:34 +02:00
|
|
|
override def trigger = allRequirements
|
|
|
|
|
|
2022-02-02 11:08:48 +01:00
|
|
|
val checkMimaFilterDirectories =
|
|
|
|
|
taskKey[Unit]("Check that the mima directories are correct compared to latest version")
|
|
|
|
|
|
2016-03-10 10:45:35 +02:00
|
|
|
override val projectSettings = Seq(
|
2020-02-28 11:50:47 +01:00
|
|
|
mimaReportSignatureProblems := true,
|
2023-08-03 11:56:28 +02:00
|
|
|
mimaPreviousArtifacts := pekkoPreviousArtifacts(name.value, organization.value),
|
2022-02-02 11:08:48 +01:00
|
|
|
checkMimaFilterDirectories := checkFilterDirectories(baseDirectory.value))
|
|
|
|
|
|
|
|
|
|
def checkFilterDirectories(moduleRoot: File): Unit = {
|
|
|
|
|
val nextVersionFilterDir =
|
2023-07-15 10:31:54 +01:00
|
|
|
moduleRoot / "src" / "main" / "mima-filters" / s"1.0.${latestPatchOf10 + 1}.backwards.excludes"
|
2022-02-02 11:08:48 +01:00
|
|
|
if (nextVersionFilterDir.exists()) {
|
|
|
|
|
throw new IllegalArgumentException(s"Incorrect mima filter directory exists: '$nextVersionFilterDir' " +
|
2023-07-15 10:31:54 +01:00
|
|
|
s"should be with number from current release '${moduleRoot / "src" / "main" / "mima-filters" / s"1.0.$latestPatchOf10.backwards.excludes"}")
|
2022-02-02 11:08:48 +01:00
|
|
|
}
|
|
|
|
|
}
|
2015-05-21 09:48:49 +03:00
|
|
|
|
2023-02-17 10:49:40 +01:00
|
|
|
def pekkoPreviousArtifacts(
|
2019-04-03 16:37:39 +02:00
|
|
|
projectName: String,
|
2023-08-03 11:56:28 +02:00
|
|
|
organization: String): Set[sbt.ModuleID] = {
|
|
|
|
|
val versions: Seq[String] = {
|
|
|
|
|
val firstPatchOf10 = 0
|
2016-12-15 16:01:32 +01:00
|
|
|
|
2023-08-03 11:56:28 +02:00
|
|
|
val pekko10Previous = expandVersions(1, 0, 0 to latestPatchOf10)
|
2019-11-06 21:40:56 +01:00
|
|
|
|
2023-08-03 11:56:28 +02:00
|
|
|
pekko10Previous
|
2021-10-27 21:19:41 +02:00
|
|
|
}
|
2023-08-03 11:56:28 +02:00
|
|
|
|
|
|
|
|
// check against all binary compatible artifacts
|
|
|
|
|
versions.map { v =>
|
|
|
|
|
organization %% projectName % v
|
|
|
|
|
}.toSet
|
2016-03-10 10:45:35 +02:00
|
|
|
}
|
2019-04-19 08:54:25 +02:00
|
|
|
|
|
|
|
|
private def expandVersions(major: Int, minor: Int, patches: immutable.Seq[Int]): immutable.Seq[String] =
|
|
|
|
|
patches.map(patch => s"$major.$minor.$patch")
|
2015-01-22 20:26:34 +02:00
|
|
|
}
|