Skip to content

Commit

Permalink
Make DependencyResolution configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed Jun 2, 2020
1 parent c3a884d commit 3cf0073
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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\".")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.typesafe.tools.mima
package plugin

import sbt._
import sbt.librarymanagement.ivy._
import sbt.Keys._
import com.typesafe.tools.mima.core.{ IncompatibleSignatureProblem, ProblemFilters }

Expand Down Expand Up @@ -38,30 +39,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,
Expand Down

0 comments on commit 3cf0073

Please sign in to comment.