mirror of https://github.com/sbt/sbt.git
Merge pull request #22 from Duhemm/fport/adds-compatibilitywarningoptions
FPORT: Adds CompatibilityWarningOptions
This commit is contained in:
commit
0b61e3c7b7
|
|
@ -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