mirror of https://github.com/sbt/sbt.git
Adds CompatibilityWarningOptions. Fixes #2347
This addresses 0.13.10 regression, which currently warns users about Maven incompatibility on a private configuration. This adds a config class so the build user can control the level of the warning as well as the target configuration to be monitored. By default, we are only going to look at `Compile` and `Runtime`.
This commit is contained in:
parent
4f2729c0b0
commit
8f88a35922
|
|
@ -1,23 +1,48 @@
|
|||
package sbt.internal.librarymanagement
|
||||
|
||||
import sbt.librarymanagement._
|
||||
import sbt.util.Logger
|
||||
import sbt.util.{ Level, Logger }
|
||||
|
||||
import Configurations._
|
||||
|
||||
final class CompatibilityWarningOptions private[sbt] (
|
||||
val configurations: Seq[Configuration],
|
||||
val level: Level.Value
|
||||
)
|
||||
|
||||
object CompatibilityWarningOptions {
|
||||
def default: CompatibilityWarningOptions =
|
||||
apply(configurations = List(Compile, Runtime), level = Level.Warn)
|
||||
def apply(
|
||||
configurations: List[Configuration],
|
||||
level: Level.Value
|
||||
): CompatibilityWarningOptions =
|
||||
new CompatibilityWarningOptions(
|
||||
configurations = configurations,
|
||||
level = level
|
||||
)
|
||||
}
|
||||
|
||||
private[sbt] object CompatibilityWarning {
|
||||
def apply(module: IvySbt#Module, mavenStyle: Boolean, log: Logger): Unit = {
|
||||
def run(config: CompatibilityWarningOptions, module: IvySbt#Module, mavenStyle: Boolean, log: Logger): Unit = {
|
||||
if (mavenStyle) {
|
||||
processIntransitive(module, log)
|
||||
processIntransitive(config, module, log)
|
||||
}
|
||||
}
|
||||
|
||||
def processIntransitive(module: IvySbt#Module, log: Logger): Unit = {
|
||||
def processIntransitive(config: CompatibilityWarningOptions, module: IvySbt#Module, log: Logger): Unit = {
|
||||
val monitoredConfigsStr: Set[String] = (config.configurations map { _.name }).toSet
|
||||
val directDependencies: Seq[ModuleID] = module.moduleSettings match {
|
||||
case x: InlineConfiguration => x.dependencies
|
||||
case x: InlineConfigurationWithExcludes => x.dependencies
|
||||
case _ => Seq()
|
||||
}
|
||||
def inMonitoredConfigs(configOpt: Option[String]): Boolean =
|
||||
configOpt match {
|
||||
case Some(c) => (c.split(",").toSet intersect monitoredConfigsStr).nonEmpty
|
||||
case None => monitoredConfigsStr contains "compile"
|
||||
}
|
||||
directDependencies foreach { m =>
|
||||
if (!m.isTransitive) {
|
||||
if (!m.isTransitive && inMonitoredConfigs(m.configurations)) {
|
||||
log.warn(
|
||||
s"""Found intransitive dependency ($m) while publishMavenStyle is true, but Maven repositories
|
||||
| do not support intransitive dependencies. Use exclusions instead so transitive dependencies
|
||||
|
|
|
|||
Loading…
Reference in New Issue