Skip to content

Commit

Permalink
Make DependencyResolution configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault committed May 27, 2020
1 parent 4546f6a commit dd1ca71
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 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 @@ -38,8 +38,12 @@ object MimaPlugin extends AutoPlugin {
)
}
},
mimaPreviousClassfiles := {
mimaDependencyResolution := {
val ivy = ivySbt.value
IvyDependencyResolution(ivy.configuration)
},
mimaPreviousClassfiles := {
val depRes = mimaDependencyResolution.value
val taskStreams = streams.value
mimaPreviousArtifacts.value match {
case _: NoPreviousArtifacts.type => NoPreviousClassfiles
Expand All @@ -49,7 +53,7 @@ object MimaPlugin extends AutoPlugin {
case Some(f) => m.withName(f(Project.normalizeModuleID(m.name)))
case None => m // no module id normalization if it's fully declaring it (using "%")
}
moduleId -> SbtMima.getPreviousArtifact(moduleId, ivy, taskStreams)
moduleId -> SbtMima.getPreviousArtifact(moduleId, depRes, taskStreams)
}.toMap
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ object SbtMima {
}

/** Resolves an artifact representing the previous abstract binary interface for testing. */
def getPreviousArtifact(m: ModuleID, ivy: IvySbt, s: TaskStreams): File = {
val depRes = IvyDependencyResolution(ivy.configuration)
def getPreviousArtifact(m: ModuleID, depRes: DependencyResolution, s: TaskStreams): File = {
val module = depRes.wrapDependencyInModule(m)
val uc = UpdateConfiguration().withLogging(UpdateLogging.DownloadOnly)
val uwc = UnresolvedWarningConfiguration()
Expand Down

0 comments on commit dd1ca71

Please sign in to comment.