diff --git a/ivy/src/main/scala/sbt/CompatibilityWarning.scala b/ivy/src/main/scala/sbt/CompatibilityWarning.scala new file mode 100644 index 000000000..7c7a7c1fb --- /dev/null +++ b/ivy/src/main/scala/sbt/CompatibilityWarning.scala @@ -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 () + } + } +} diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/MakePom.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/MakePom.scala index ea4990736..e52bb165b 100644 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/MakePom.scala +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/MakePom.scala @@ -238,31 +238,21 @@ class MakePom(val log: Logger) { def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String]): NodeSeq = makeDependency(dependency, includeTypes, Nil) - def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String], excludes: Seq[ExcludeRule]): NodeSeq = { - def warnIntransitve(): Unit = - if (!dependency.isTransitive) - log.warn( - s"""Translating intransitive dependency (${dependency.getDependencyId}) into pom.xml, but maven does not support intransitive dependencies. - | Please use exclusions instead so transitive dependencies will be correctly excluded in dependent projects. - """.stripMargin - ) - else () - val artifacts = dependency.getAllDependencyArtifacts - val includeArtifacts = artifacts.filter(d => includeTypes(d.getType)) - if (artifacts.isEmpty) { - val configs = dependency.getModuleConfigurations - if (!configs.forall(Set("sources", "docs"))) { - warnIntransitve() - 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))) + def makeDependency(dependency: DependencyDescriptor, includeTypes: Set[String], excludes: Seq[ExcludeRule]): NodeSeq = + { + val artifacts = dependency.getAllDependencyArtifacts + val includeArtifacts = artifacts.filter(d => includeTypes(d.getType)) + if (artifacts.isEmpty) { + val configs = dependency.getModuleConfigurations + if (configs.filterNot(Set("sources", "docs")).nonEmpty) { + val (scope, optional) = getScopeAndOptional(dependency.getModuleConfigurations) + makeDependencyElem(dependency, scope, optional, None, None, excludes) + } else NodeSeq.Empty + } else if (includeArtifacts.isEmpty) + NodeSeq.Empty + else + NodeSeq.fromSeq(artifacts.flatMap(a => makeDependencyElem(dependency, a, excludes))) } - } @deprecated("Use `makeDependencyElem` variant which takes excludes", "0.13.9") def makeDependencyElem(dependency: DependencyDescriptor, artifact: DependencyArtifactDescriptor): Option[Elem] =