Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make DependencyResolution configurable #509

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,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,
Expand Down