Skip to content

Commit 589743b

Browse files
authored
General MiMa sbt setup improvements (#59)
General MiMa sbt setup improvements
2 parents 9d3d2c7 + 188a830 commit 589743b

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

src/main/scala/ScalaModulePlugin.scala

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,8 @@ object ScalaModulePlugin extends AutoPlugin {
159159
val moduleId = ModuleID(organization, s"${name}_$scalaBinaryVersion", version)
160160
val depRes = IvyDependencyResolution(ivy.configuration)
161161
val module = depRes.wrapDependencyInModule(moduleId)
162-
val reportEither = depRes.update(
163-
module,
164-
UpdateConfiguration() withLogging UpdateLogging.DownloadOnly,
165-
UnresolvedWarningConfiguration(),
166-
s.log
167-
)
162+
val updateConf = UpdateConfiguration() withLogging UpdateLogging.DownloadOnly
163+
val reportEither = depRes.update(module, updateConf, UnresolvedWarningConfiguration(), s.log)
168164
reportEither.fold(_ => false, _ => true)
169165
}
170166

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

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

181177
canRunMima := {
182-
val mimaVer = mimaPreviousVersion.value
183-
val s = streams.value
184-
val ivySbt = Keys.ivySbt.value
185-
if (mimaVer.isEmpty) {
186-
s.log.warn("MiMa will NOT run because no mimaPreviousVersion is provided.")
187-
false
188-
} else if (!artifactExists(organization.value, name.value, scalaBinaryVersion.value, mimaVer.get, ivySbt, s)) {
189-
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).""")
190-
false
191-
} else {
192-
true
178+
val log = streams.value.log
179+
mimaPreviousVersion.value match {
180+
case None =>
181+
log.warn("MiMa will NOT run because no mimaPreviousVersion is provided.")
182+
false
183+
case Some(mimaVer) =>
184+
val exists = artifactExists(organization.value, name.value, scalaBinaryVersion.value, mimaVer, ivySbt.value, streams.value)
185+
if (!exists)
186+
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).""")
187+
exists
193188
}
194189
},
195190

196191
runMimaIfEnabled := Def.taskDyn({
197-
if(canRunMima.value) Def.task { mimaReportBinaryIssues.value }
192+
if (canRunMima.value) Def.task { mimaReportBinaryIssues.value }
198193
else Def.task { () }
199194
}).value,
200195

0 commit comments

Comments
 (0)