diff --git a/sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala b/sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala index a71ec59fb..2951f6eda 100644 --- a/sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala +++ b/sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala @@ -23,6 +23,10 @@ object SbtCompatibility { id.copy(configurations = configurations) def withExtraAttributes(extraAttributes: Map[String, String]): sbt.ModuleID = id.copy(extraAttributes = extraAttributes) + def withExclusions(exclusions: Seq[sbt.librarymanagement.InclExclRule]): sbt.ModuleID = + exclusions.foldLeft(id)((id0, rule) => id0.exclude(rule.org, rule.name)) + def withIsTransitive(isTransitive: Boolean): sbt.ModuleID = + id.copy(isTransitive = isTransitive) } implicit class ArtifactOps(val artifact: sbt.Artifact) extends AnyVal { diff --git a/sbt-coursier/src/main/scala/coursier/ToSbt.scala b/sbt-coursier/src/main/scala/coursier/ToSbt.scala index 2c4db0c9e..24c3a16a8 100644 --- a/sbt-coursier/src/main/scala/coursier/ToSbt.scala +++ b/sbt-coursier/src/main/scala/coursier/ToSbt.scala @@ -33,6 +33,18 @@ object ToSbt { Some(dependency.configuration) ).withExtraAttributes( dependency.module.attributes ++ extraProperties + ).withExclusions( + dependency + .exclusions + .toVector + .map { + case (org, name) => + sbt.librarymanagement.InclExclRule() + .withOrganization(org) + .withName(name) + } + ).withIsTransitive( + dependency.transitive ) } diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/build.sbt b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/build.sbt new file mode 100644 index 000000000..d4fce7575 --- /dev/null +++ b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/build.sbt @@ -0,0 +1,32 @@ + +import Compatibility._ + +lazy val noJbossInterceptorCheck = TaskKey[Unit]("noJbossInterceptorCheck") + +noJbossInterceptorCheck := { + + val log = streams.value.log + + val configReport = updateSbtClassifiers.value + .configuration(Default) + .getOrElse { + throw new Exception( + "compile configuration not found in update report" + ) + } + + val artifacts = configReport + .modules + .flatMap(_.artifacts) + .map(_._1) + + val jbossInterceptorArtifacts = artifacts + .filter { a => + a.name.contains("jboss-interceptor") + } + + for (a <- jbossInterceptorArtifacts) + log.error(s"Found jboss-interceptor artifact $a") + + assert(jbossInterceptorArtifacts.isEmpty) +} diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/plugins.sbt b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/plugins.sbt new file mode 100644 index 000000000..a0c118db1 --- /dev/null +++ b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/plugins.sbt @@ -0,0 +1,13 @@ +{ + val pluginVersion = sys.props.getOrElse( + "plugin.version", + throw new RuntimeException( + """|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) + ) + + addSbtPlugin("io.get-coursier" % "sbt-coursier" % pluginVersion) +} + +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6") diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/project/plugins.sbt b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/project/plugins.sbt new file mode 100644 index 000000000..152225a9e --- /dev/null +++ b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/project/plugins.sbt @@ -0,0 +1,11 @@ +{ + val pluginVersion = sys.props.getOrElse( + "plugin.version", + throw new RuntimeException( + """|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin + ) + ) + + addSbtPlugin("io.get-coursier" % "sbt-coursier" % pluginVersion) +} diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/src/main/scala-2.10/Compatibility.scala b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/src/main/scala-2.10/Compatibility.scala new file mode 100644 index 000000000..8824f1209 --- /dev/null +++ b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/src/main/scala-2.10/Compatibility.scala @@ -0,0 +1,8 @@ +object Compatibility { + + implicit class UpdateReportOps(val rep: sbt.UpdateReport) extends AnyVal { + def configuration(conf: sbt.Configuration) = + rep.configuration(conf.name) + } + +} diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/src/main/scala-2.12/Compatibility.scala b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/src/main/scala-2.12/Compatibility.scala new file mode 100644 index 000000000..19835e1be --- /dev/null +++ b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/project/src/main/scala-2.12/Compatibility.scala @@ -0,0 +1 @@ +object Compatibility diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/test b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/test new file mode 100644 index 000000000..b06452c35 --- /dev/null +++ b/sbt-coursier/src/sbt-test/sbt-coursier/sbt-assembly/test @@ -0,0 +1 @@ +> noJbossInterceptorCheck diff --git a/sbt-shared/src/main/scala-2.10/sbt/librarymanagement/InclExclRule.scala b/sbt-shared/src/main/scala-2.10/sbt/librarymanagement/InclExclRule.scala new file mode 100644 index 000000000..72bd82e77 --- /dev/null +++ b/sbt-shared/src/main/scala-2.10/sbt/librarymanagement/InclExclRule.scala @@ -0,0 +1,8 @@ +package sbt.librarymanagement + +final case class InclExclRule(org: String = "*", name: String = "*") { + def withOrganization(org: String): InclExclRule = + copy(org = org) + def withName(name: String): InclExclRule = + copy(name = name) +}