diff --git a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaKeys.scala b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaKeys.scala index d30f77c3..73bcd74b 100644 --- a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaKeys.scala +++ b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaKeys.scala @@ -3,6 +3,7 @@ package plugin import com.typesafe.tools.mima.core.{ Problem, ProblemFilter } import sbt.{ File, ModuleID, settingKey, taskKey } // no sbt._, to avoid 1.3+ only singleFileJsonFormatter +import sbt.librarymanagement.DependencyResolution object MimaKeys extends MimaKeys @@ -15,6 +16,7 @@ class MimaKeys { final val mimaFailOnNoPrevious = settingKey[Boolean]("if true, fail the build if no previous artifacts are set.") final val mimaReportSignatureProblems = settingKey[Boolean]("if true, report `IncompatibleSignatureProblem`s.") + final val mimaDependencyResolution = taskKey[DependencyResolution]("DependencyResolution to use to fetch previous artifacts.") final val mimaPreviousClassfiles = taskKey[Map[ModuleID, File]]("Directories or jars containing the previous class files used to test compatibility with a given module.") final val mimaCurrentClassfiles = taskKey[File]("Directory or jar containing the current class files used to test compatibility.") final val mimaCheckDirection = settingKey[String]("Compatibility checking direction; default is \"backward\", but can also be \"forward\" or \"both\".") diff --git a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala index 9cfb63f1..b7cc58cc 100644 --- a/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala +++ b/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/MimaPlugin.scala @@ -38,30 +38,29 @@ object MimaPlugin extends AutoPlugin { ) } }, - mimaPreviousClassfiles := (Def.taskDyn { - val depResTask = SbtMima.csrConfigurationKeyOpt match { + mimaDependencyResolution := (Def.taskDyn { + SbtMima.csrConfigurationKeyOpt match { case None => SbtMima.ivyDependencyResolution case Some(csrConfiguration) => SbtMima.csrDependencyResolution(csrConfiguration) } - - Def.task { - val depRes = depResTask.value - val taskStreams = streams.value - mimaPreviousArtifacts.value match { - case _: NoPreviousArtifacts.type => NoPreviousClassfiles - case previousArtifacts => - previousArtifacts.iterator.map { m => - val moduleId = CrossVersion(m, scalaModuleInfo.value) match { - case Some(f) => m.withName(f(m.name)) - case None => m - } - moduleId -> SbtMima.getPreviousArtifact(moduleId, depRes, taskStreams) - }.toMap - } - } }).value, + mimaPreviousClassfiles := { + val depRes = mimaDependencyResolution.value + val taskStreams = streams.value + mimaPreviousArtifacts.value match { + case _: NoPreviousArtifacts.type => NoPreviousClassfiles + case previousArtifacts => + previousArtifacts.iterator.map { m => + val moduleId = CrossVersion(m, scalaModuleInfo.value) match { + case Some(f) => m.withName(f(m.name)) + case None => m + } + moduleId -> SbtMima.getPreviousArtifact(moduleId, depRes, taskStreams) + }.toMap + } + }, mimaCurrentClassfiles := (classDirectory in Compile).value, mimaFindBinaryIssues := binaryIssuesIterator.value.toMap, fullClasspath in mimaFindBinaryIssues := (fullClasspath in Compile).value,