mirror of https://github.com/sbt/sbt.git
Move intransitive warning to update. Ref #2127
This commit is contained in:
parent
bfb602c29b
commit
e82e6652d0
|
|
@ -0,0 +1,25 @@
|
||||||
|
package sbt
|
||||||
|
|
||||||
|
private[sbt] object CompatibilityWarning {
|
||||||
|
def apply(module: IvySbt#Module, mavenStyle: Boolean, log: Logger): Unit = {
|
||||||
|
if (mavenStyle) {
|
||||||
|
processIntransitive(module, log)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def processIntransitive(module: IvySbt#Module, log: Logger): Unit = {
|
||||||
|
val directDependencies: Seq[ModuleID] = module.moduleSettings match {
|
||||||
|
case x: InlineConfiguration => x.dependencies
|
||||||
|
case x: InlineConfigurationWithExcludes => x.dependencies
|
||||||
|
case _ => Seq()
|
||||||
|
}
|
||||||
|
directDependencies foreach { m =>
|
||||||
|
if (!m.isTransitive) {
|
||||||
|
log.warn(
|
||||||
|
s"""Found intransitive dependency ($m), but maven does not support intransitive dependencies.
|
||||||
|
| Use exclusions instead so transitive dependencies will be correctly excluded in dependent projects.
|
||||||
|
""".stripMargin)
|
||||||
|
} else ()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -235,30 +235,21 @@ class MakePom(val log: Logger) {
|
||||||
def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String]): NodeSeq =
|
def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String]): NodeSeq =
|
||||||
makeDependency(dependency, includeTypes, Nil)
|
makeDependency(dependency, includeTypes, Nil)
|
||||||
|
|
||||||
def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String], excludes: Seq[ExcludeRule]): NodeSeq = {
|
def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String], excludes: Seq[ExcludeRule]): NodeSeq =
|
||||||
def warnIntransitve(): Unit =
|
{
|
||||||
if (!dependency.isTransitive)
|
val artifacts = dependency.getAllDependencyArtifacts
|
||||||
log.warn(
|
val includeArtifacts = artifacts.filter(d => includeTypes(d.getType))
|
||||||
s"""Translating intransitive dependency (${dependency.getDependencyId}) into pom.xml, but maven does not support intransitive dependencies.
|
if (artifacts.isEmpty) {
|
||||||
| Please use exclusions instead so transitive dependencies will be correctly excluded in dependent projects.
|
val configs = dependency.getModuleConfigurations
|
||||||
""".stripMargin)
|
if (configs.filterNot(Set("sources", "docs")).nonEmpty) {
|
||||||
else ()
|
val (scope, optional) = getScopeAndOptional(dependency.getModuleConfigurations)
|
||||||
val artifacts = dependency.getAllDependencyArtifacts
|
makeDependencyElem(dependency, scope, optional, None, None, excludes)
|
||||||
val includeArtifacts = artifacts.filter(d => includeTypes(d.getType))
|
} else NodeSeq.Empty
|
||||||
if (artifacts.isEmpty) {
|
} else if (includeArtifacts.isEmpty)
|
||||||
val configs = dependency.getModuleConfigurations
|
NodeSeq.Empty
|
||||||
if (!configs.forall(Set("sources", "docs"))) {
|
else
|
||||||
warnIntransitve()
|
NodeSeq.fromSeq(artifacts.flatMap(a => makeDependencyElem(dependency, a, excludes)))
|
||||||
val (scope, optional) = getScopeAndOptional(dependency.getModuleConfigurations)
|
|
||||||
makeDependencyElem(dependency, scope, optional, None, None, excludes)
|
|
||||||
} else NodeSeq.Empty
|
|
||||||
} else if (includeArtifacts.isEmpty) {
|
|
||||||
NodeSeq.Empty
|
|
||||||
} else {
|
|
||||||
warnIntransitve()
|
|
||||||
NodeSeq.fromSeq(artifacts.flatMap(a => makeDependencyElem(dependency, a, excludes)))
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@deprecated("Use `makeDependencyElem` variant which takes excludes", "0.13.9")
|
@deprecated("Use `makeDependencyElem` variant which takes excludes", "0.13.9")
|
||||||
def makeDependencyElem(dependency: DependencyDescriptor, artifact: DependencyArtifactDescriptor): Option[Elem] =
|
def makeDependencyElem(dependency: DependencyDescriptor, artifact: DependencyArtifactDescriptor): Option[Elem] =
|
||||||
|
|
|
||||||
|
|
@ -1384,6 +1384,7 @@ object Classpaths {
|
||||||
val logicalClock = LogicalClock(st.hashCode)
|
val logicalClock = LogicalClock(st.hashCode)
|
||||||
val depDir = dependencyCacheDirectory.value
|
val depDir = dependencyCacheDirectory.value
|
||||||
val uc0 = updateConfiguration.value
|
val uc0 = updateConfiguration.value
|
||||||
|
val ms = publishMavenStyle.value
|
||||||
// Normally, log would capture log messages at all levels.
|
// Normally, log would capture log messages at all levels.
|
||||||
// Ivy logs are treated specially using sbt.UpdateConfiguration.logging.
|
// Ivy logs are treated specially using sbt.UpdateConfiguration.logging.
|
||||||
// This code bumps up the sbt.UpdateConfiguration.logging to Full when logLevel is Debug.
|
// This code bumps up the sbt.UpdateConfiguration.logging to Full when logLevel is Debug.
|
||||||
|
|
@ -1399,17 +1400,17 @@ object Classpaths {
|
||||||
cachedUpdate(s.cacheDirectory / updateCacheName.value, show, ivyModule.value, uc, transform,
|
cachedUpdate(s.cacheDirectory / updateCacheName.value, show, ivyModule.value, uc, transform,
|
||||||
skip = (skip in update).value, force = isRoot || forceUpdateByTime, depsUpdated = depsUpdated,
|
skip = (skip in update).value, force = isRoot || forceUpdateByTime, depsUpdated = depsUpdated,
|
||||||
uwConfig = uwConfig, logicalClock = logicalClock, depDir = Some(depDir),
|
uwConfig = uwConfig, logicalClock = logicalClock, depDir = Some(depDir),
|
||||||
ewo = ewo, log = s.log)
|
ewo = ewo, mavenStyle = ms, log = s.log)
|
||||||
}
|
}
|
||||||
@deprecated("Use cachedUpdate with the variant that takes unresolvedHandler instead.", "0.13.6")
|
@deprecated("Use cachedUpdate with the variant that takes unresolvedHandler instead.", "0.13.6")
|
||||||
def cachedUpdate(cacheFile: File, label: String, module: IvySbt#Module, config: UpdateConfiguration,
|
def cachedUpdate(cacheFile: File, label: String, module: IvySbt#Module, config: UpdateConfiguration,
|
||||||
transform: UpdateReport => UpdateReport, skip: Boolean, force: Boolean, depsUpdated: Boolean, log: Logger): UpdateReport =
|
transform: UpdateReport => UpdateReport, skip: Boolean, force: Boolean, depsUpdated: Boolean, log: Logger): UpdateReport =
|
||||||
cachedUpdate(cacheFile, label, module, config, transform, skip, force, depsUpdated,
|
cachedUpdate(cacheFile, label, module, config, transform, skip, force, depsUpdated,
|
||||||
UnresolvedWarningConfiguration(), LogicalClock.unknown, None, EvictionWarningOptions.empty, log)
|
UnresolvedWarningConfiguration(), LogicalClock.unknown, None, EvictionWarningOptions.empty, true, log)
|
||||||
private[sbt] def cachedUpdate(cacheFile: File, label: String, module: IvySbt#Module, config: UpdateConfiguration,
|
private[sbt] def cachedUpdate(cacheFile: File, label: String, module: IvySbt#Module, config: UpdateConfiguration,
|
||||||
transform: UpdateReport => UpdateReport, skip: Boolean, force: Boolean, depsUpdated: Boolean,
|
transform: UpdateReport => UpdateReport, skip: Boolean, force: Boolean, depsUpdated: Boolean,
|
||||||
uwConfig: UnresolvedWarningConfiguration, logicalClock: LogicalClock, depDir: Option[File],
|
uwConfig: UnresolvedWarningConfiguration, logicalClock: LogicalClock, depDir: Option[File],
|
||||||
ewo: EvictionWarningOptions, log: Logger): UpdateReport =
|
ewo: EvictionWarningOptions, mavenStyle: Boolean, log: Logger): UpdateReport =
|
||||||
{
|
{
|
||||||
implicit val updateCache = updateIC
|
implicit val updateCache = updateIC
|
||||||
type In = IvyConfiguration :+: ModuleSettings :+: UpdateConfiguration :+: HNil
|
type In = IvyConfiguration :+: ModuleSettings :+: UpdateConfiguration :+: HNil
|
||||||
|
|
@ -1428,6 +1429,7 @@ object Classpaths {
|
||||||
val ew = EvictionWarning(module, ewo, result, log)
|
val ew = EvictionWarning(module, ewo, result, log)
|
||||||
ew.lines foreach { log.warn(_) }
|
ew.lines foreach { log.warn(_) }
|
||||||
ew.infoAllTheThings foreach { log.info(_) }
|
ew.infoAllTheThings foreach { log.info(_) }
|
||||||
|
val cw = CompatibilityWarning(module, mavenStyle, log)
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
def uptodate(inChanged: Boolean, out: UpdateReport): Boolean =
|
def uptodate(inChanged: Boolean, out: UpdateReport): Boolean =
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|
||||||
- Scala version used by the build is updated to 2.10.6. [#2311][2311] by [@eed3si9n][@eed3si9n]
|
- Scala version used by the build is updated to 2.10.6. [#2311][2311] by [@eed3si9n][@eed3si9n]
|
||||||
- `makePom` warns when it sees intransitive dependencies, which do not translate to Maven. [#2127][2127] by [@jsuereth][@jsuereth]
|
- If `publishMavenStyle` is `true`, `update` task warns when it sees intransitive dependencies, which do not translate to Maven. [#2127][2127] by [@jsuereth][@jsuereth]
|
||||||
- Adds `Def.settings`, which facilitates mixing settings with seq of settings. See below.
|
- Adds `Def.settings`, which facilitates mixing settings with seq of settings. See below.
|
||||||
- Adds configurable compiler bridge. See below.
|
- Adds configurable compiler bridge. See below.
|
||||||
- sbt Serialization is updated to 0.1.2. [2117][#2117] by [@dwijnand][@dwijnand]
|
- sbt Serialization is updated to 0.1.2. [2117][#2117] by [@dwijnand][@dwijnand]
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,22 @@
|
||||||
scalaVersion := "2.10.2"
|
|
||||||
|
|
||||||
libraryDependencies += "org.scala-sbt" %% "sbinary" % "0.4.1" withSources() withJavadoc()
|
|
||||||
libraryDependencies += "org.scala-sbt" % "io" % "0.13.8" intransitive()
|
|
||||||
|
|
||||||
lazy val checkPom = taskKey[Unit]("check pom to ensure no <type> sections are generated")
|
lazy val checkPom = taskKey[Unit]("check pom to ensure no <type> sections are generated")
|
||||||
|
|
||||||
checkPom := {
|
lazy val root = (project in file(".")).
|
||||||
val pomFile = makePom.value
|
settings(
|
||||||
val pom = xml.XML.loadFile(pomFile)
|
scalaVersion := "2.10.6",
|
||||||
val tpe = pom \\ "type"
|
libraryDependencies += "org.scala-tools.sbinary" %% "sbinary" % "0.4.1" withSources() withJavadoc(),
|
||||||
if(tpe.nonEmpty) {
|
libraryDependencies += "org.scala-sbt" % "io" % "0.13.8" intransitive(),
|
||||||
sys.error("Expected no <type> sections, got: " + tpe + " in \n\n" + pom)
|
checkPom := {
|
||||||
}
|
val pomFile = makePom.value
|
||||||
val dir = (streams in makePom).value.cacheDirectory / "out"
|
val pom = xml.XML.loadFile(pomFile)
|
||||||
val lines = IO.readLines(dir)
|
val tpe = pom \\ "type"
|
||||||
val hasError = lines exists { line => line contains "Translating intransitive dependency "}
|
if(tpe.nonEmpty) {
|
||||||
assert(hasError, s"Failed to detect intransitive dependencies, got: ${lines.mkString("\n")}")
|
sys.error("Expected no <type> sections, got: " + tpe + " in \n\n" + pom)
|
||||||
}
|
}
|
||||||
|
val ur = update.value
|
||||||
|
val dir = (streams in update).value.cacheDirectory / "out"
|
||||||
|
val lines = IO.readLines(dir)
|
||||||
|
val hasError = lines exists { line => line contains "Found intransitive dependency "}
|
||||||
|
assert(hasError, s"Failed to detect intransitive dependencies, got: ${lines.mkString("\n")}")
|
||||||
|
},
|
||||||
|
resolvers += Resolver.typesafeIvyRepo("releases")
|
||||||
|
)
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
> checkPom
|
> checkPom
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue