Skip to content

General MiMa sbt setup improvements #59

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

Merged
merged 1 commit into from
Jul 5, 2019
Merged
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
33 changes: 14 additions & 19 deletions src/main/scala/ScalaModulePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,8 @@ object ScalaModulePlugin extends AutoPlugin {
val moduleId = ModuleID(organization, s"${name}_$scalaBinaryVersion", version)
val depRes = IvyDependencyResolution(ivy.configuration)
val module = depRes.wrapDependencyInModule(moduleId)
val reportEither = depRes.update(
module,
UpdateConfiguration() withLogging UpdateLogging.DownloadOnly,
UnresolvedWarningConfiguration(),
s.log
)
val updateConf = UpdateConfiguration() withLogging UpdateLogging.DownloadOnly
val reportEither = depRes.update(module, updateConf, UnresolvedWarningConfiguration(), s.log)
reportEither.fold(_ => false, _ => true)
}

Expand All @@ -176,25 +172,24 @@ object ScalaModulePlugin extends AutoPlugin {
mimaPreviousVersion := None,

// We're not using `%%` here in order to support both jvm and js projects (cross version `_2.12` / `_sjs0.6_2.12`)
mimaPreviousArtifacts := Set(organization.value % moduleName.value % mimaPreviousVersion.value.getOrElse("dummy") cross crossVersion.value),
mimaPreviousArtifacts := mimaPreviousVersion.value.map(v => organization.value % moduleName.value % v cross crossVersion.value).toSet,

canRunMima := {
val mimaVer = mimaPreviousVersion.value
val s = streams.value
val ivySbt = Keys.ivySbt.value
if (mimaVer.isEmpty) {
s.log.warn("MiMa will NOT run because no mimaPreviousVersion is provided.")
false
} else if (!artifactExists(organization.value, name.value, scalaBinaryVersion.value, mimaVer.get, ivySbt, s)) {
s.log.warn(s"""MiMa will NOT run because the previous artifact "${organization.value}" % "${name.value}_${scalaBinaryVersion.value}" % "${mimaVer.get}" could not be resolved (note the binary Scala version).""")
false
} else {
true
val log = streams.value.log
mimaPreviousVersion.value match {
case None =>
log.warn("MiMa will NOT run because no mimaPreviousVersion is provided.")
false
case Some(mimaVer) =>
val exists = artifactExists(organization.value, name.value, scalaBinaryVersion.value, mimaVer, ivySbt.value, streams.value)
if (!exists)
log.warn(s"""MiMa will NOT run because the previous artifact "${organization.value}" % "${name.value}_${scalaBinaryVersion.value}" % "$mimaVer" could not be resolved (note the binary Scala version).""")
exists
}
},

runMimaIfEnabled := Def.taskDyn({
if(canRunMima.value) Def.task { mimaReportBinaryIssues.value }
if (canRunMima.value) Def.task { mimaReportBinaryIssues.value }
else Def.task { () }
}).value,

Expand Down