-
Notifications
You must be signed in to change notification settings - Fork 15
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
Facilitate using the plugin for custom reports #121
base: main
Are you sure you want to change the base?
Changes from all commits
4a1ab6f
7dc19ac
bd7b3e8
0ead71a
a89f41f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -93,22 +93,25 @@ object SbtVersionPolicySettings { | |||||
|
||||||
def previousArtifactsSettings = Def.settings( | ||||||
versionPolicyPreviousArtifactsFromMima := { | ||||||
import Ordering.Implicits._ | ||||||
MimaPlugin.autoImport.mimaPreviousArtifacts.value | ||||||
.toVector | ||||||
.map { mod => | ||||||
val splitVersion = mod.revision.split('.').map(s => Try(s.toInt).getOrElse(-1)).toSeq | ||||||
(splitVersion, mod) | ||||||
} | ||||||
.sortBy(_._1) | ||||||
.map(_._2) | ||||||
fromMimaArtifacts(MimaPlugin.autoImport.mimaPreviousArtifacts.value) | ||||||
}, | ||||||
|
||||||
versionPolicyPreviousArtifacts := versionPolicyPreviousArtifactsFromMima.value | ||||||
) | ||||||
|
||||||
def fromMimaArtifacts(artifacts: Set[sbt.ModuleID]) = { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
import Ordering.Implicits.* | ||||||
artifacts | ||||||
.toVector | ||||||
.map { mod => | ||||||
val splitVersion = mod.revision.split('.').map(s => Try(s.toInt).getOrElse(-1)).toSeq | ||||||
(splitVersion, mod) | ||||||
} | ||||||
.sortBy(_._1) | ||||||
.map(_._2) | ||||||
} | ||||||
|
||||||
def findIssuesSettings = Def.settings( | ||||||
versionPolicyFindDependencyIssues := { | ||||||
versionPolicyDependencyIssuesReporter := { | ||||||
val log = streams.value.log | ||||||
val sv = scalaVersion.value | ||||||
val sbv = scalaBinaryVersion.value | ||||||
|
@@ -117,9 +120,6 @@ object SbtVersionPolicySettings { | |||||
sys.error("Compile configuration not found in update report") | ||||||
} | ||||||
|
||||||
val compatibilityIntention = | ||||||
versionPolicyIntention.?.value | ||||||
.getOrElse(throw new MessageOnlyException("Please set the key versionPolicyIntention to declare the compatibility you want to check")) | ||||||
val depRes = versionPolicyDependencyResolution.value | ||||||
val scalaModuleInf = versionPolicyScalaModuleInfo.value | ||||||
val updateConfig = versionPolicyUpdateConfiguration.value | ||||||
|
@@ -140,42 +140,32 @@ object SbtVersionPolicySettings { | |||||
log | ||||||
) | ||||||
|
||||||
new DependencyCheck.Reporter( | ||||||
excludedModules, | ||||||
currentDependencies, | ||||||
reconciliations, | ||||||
VersionCompatibility.Strict, | ||||||
sv, | ||||||
sbv, | ||||||
depRes, | ||||||
scalaModuleInf, | ||||||
updateConfig, | ||||||
warningConfig, | ||||||
log | ||||||
) | ||||||
}, | ||||||
versionPolicyFindDependencyIssues := { | ||||||
val compatibilityIntention = requirePolicyIntentionOrThrow(versionPolicyIntention.?.value) | ||||||
val previousModuleIds = versionPolicyPreviousArtifacts.value | ||||||
|
||||||
// Skip dependency check if no compatibility is intended | ||||||
if (compatibilityIntention == Compatibility.None) Nil else { | ||||||
|
||||||
previousModuleIds.map { previousModuleId => | ||||||
|
||||||
val report0 = DependencyCheck.report( | ||||||
compatibilityIntention, | ||||||
excludedModules, | ||||||
currentDependencies, | ||||||
previousModuleId, | ||||||
reconciliations, | ||||||
VersionCompatibility.Strict, | ||||||
sv, | ||||||
sbv, | ||||||
depRes, | ||||||
scalaModuleInf, | ||||||
updateConfig, | ||||||
warningConfig, | ||||||
log | ||||||
) | ||||||
|
||||||
(previousModuleId, report0) | ||||||
} | ||||||
} | ||||||
versionPolicyDependencyIssuesReporter.value.apply(compatibilityIntention, previousModuleIds) | ||||||
}, | ||||||
versionPolicyReportDependencyIssues := { | ||||||
val log = streams.value.log | ||||||
val sv = scalaVersion.value | ||||||
val sbv = scalaBinaryVersion.value | ||||||
val direction = versionPolicyCheckDirection.value | ||||||
val reports = versionPolicyFindDependencyIssues.value | ||||||
val intention = | ||||||
versionPolicyIntention.?.value | ||||||
.getOrElse(throw new MessageOnlyException("Please set the key versionPolicyIntention to declare the compatibility you want to check")) | ||||||
val intention = requirePolicyIntentionOrThrow(versionPolicyIntention.?.value) | ||||||
val currentModule = projectID.value | ||||||
val formattedPreviousVersions = formatVersions(versionPolicyPreviousVersions.value) | ||||||
|
||||||
|
@@ -263,9 +253,7 @@ object SbtVersionPolicySettings { | |||||
}, | ||||||
versionPolicyMimaCheck := Def.taskDyn { | ||||||
import Compatibility._ | ||||||
val compatibility = | ||||||
versionPolicyIntention.?.value | ||||||
.getOrElse(throw new MessageOnlyException("Please set the key versionPolicyIntention to declare the compatibility you want to check")) | ||||||
val compatibility = requirePolicyIntentionOrThrow(versionPolicyIntention.?.value) | ||||||
val log = streams.value.log | ||||||
val currentModule = projectID.value | ||||||
val formattedPreviousVersions = formatVersions(versionPolicyPreviousVersions.value) | ||||||
|
@@ -302,6 +290,14 @@ object SbtVersionPolicySettings { | |||||
}.value | ||||||
) | ||||||
|
||||||
private def requirePolicyIntentionOrThrow(maybeCompatibility: Option[Compatibility]) = | ||||||
maybeCompatibility | ||||||
.getOrElse( | ||||||
throw new MessageOnlyException( | ||||||
"Please set the key versionPolicyIntention to declare the compatibility you want to check" | ||||||
) | ||||||
) | ||||||
|
||||||
def skipSettings = Seq( | ||||||
versionCheck / skip := (publish / skip).value, | ||||||
versionPolicyCheck / skip := (publish / skip).value | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -75,6 +75,47 @@ object DependencyCheck { | |||||
log | ||||||
) | ||||||
|
||||||
class Reporter( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind adding some documentation? |
||||||
excludedModules: Set[(String, String)], | ||||||
currentDependencies: Map[(String, String), String], | ||||||
reconciliations: Seq[(ModuleMatchers, VersionCompatibility)], | ||||||
defaultReconciliation: VersionCompatibility, | ||||||
sv: String, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
scalaBinaryVersion: String, | ||||||
depRes: DependencyResolution, | ||||||
scalaModuleInf: Option[ScalaModuleInfo], | ||||||
updateConfig: UpdateConfiguration, | ||||||
warningConfig: UnresolvedWarningConfiguration, | ||||||
log: Logger | ||||||
) { | ||||||
def apply(compatibilityIntention: Compatibility, previousModuleIds: Seq[ModuleID]) = | ||||||
// Skip dependency check if no compatibility is intended | ||||||
if (compatibilityIntention == Compatibility.None) Nil else { | ||||||
|
||||||
previousModuleIds.map { previousModuleId => | ||||||
|
||||||
val report0 = report( | ||||||
compatibilityIntention, | ||||||
excludedModules, | ||||||
currentDependencies, | ||||||
previousModuleId, | ||||||
reconciliations, | ||||||
defaultReconciliation, | ||||||
sv, | ||||||
sbv, | ||||||
depRes, | ||||||
scalaModuleInf, | ||||||
updateConfig, | ||||||
warningConfig, | ||||||
log | ||||||
) | ||||||
|
||||||
(previousModuleId, report0) | ||||||
} | ||||||
} | ||||||
|
||||||
} | ||||||
|
||||||
private[sbtversionpolicy] def report( | ||||||
compatibilityIntention: Compatibility, | ||||||
excludedModules: Set[(String, String)], | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.