diff --git a/appveyor.yml b/appveyor.yml index c65df78ad..5da959559 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,8 +18,8 @@ build_script: - sbt ++2.11.11 clean compile coreJVM/publishLocal cli/publishLocal - sbt ++2.12.4 http-server/publishLocal - sbt ++2.10.6 clean compile - - sbt ++2.12.4 coreJVM/publishLocal cache/publishLocal extra/publishLocal # to make the scripted sbt 1.0 tests happy - - sbt ++2.10.6 coreJVM/publishLocal cache/publishLocal extra/publishLocal # to make the scripted sbt 0.13 tests happy + - sbt ++2.12.4 coreJVM/publishLocal cache/publishLocal extra/publishLocal sbt-shared/publishLocal # to make the scripted sbt 1.0 tests happy + - sbt ++2.10.6 coreJVM/publishLocal cache/publishLocal extra/publishLocal sbt-shared/publishLocal # to make the scripted sbt 0.13 tests happy test_script: - ps: Start-Job -filepath .\scripts\start-it-auth-server.ps1 -ArgumentList $pwd - ps: Start-Sleep -s 15 # wait for the first server to have downloaded its dependencies diff --git a/build.sbt b/build.sbt index 15d44c031..5a8a74d83 100644 --- a/build.sbt +++ b/build.sbt @@ -217,8 +217,15 @@ lazy val doc = project tutTargetDirectory := baseDirectory.in(LocalRootProject).value ) +lazy val `sbt-shared` = project + .dependsOn(coreJvm, cache) + .settings( + plugin, + utest + ) + lazy val `sbt-coursier` = project - .dependsOn(coreJvm, cache, extra) + .dependsOn(coreJvm, cache, extra, `sbt-shared`) .settings( plugin, utest @@ -307,6 +314,7 @@ lazy val jvm = project bootstrap, extra, cli, + `sbt-shared`, `sbt-coursier`, `sbt-pgp-coursier`, `sbt-shading`, @@ -343,6 +351,7 @@ lazy val `sbt-plugins` = project coreJvm, cache, extra, + `sbt-shared`, `sbt-coursier`, `sbt-pgp-coursier`, `sbt-shading` @@ -366,6 +375,7 @@ lazy val coursier = project bootstrap, extra, cli, + `sbt-shared`, `sbt-coursier`, `sbt-pgp-coursier`, `sbt-shading`, diff --git a/project/Settings.scala b/project/Settings.scala index 81d4d332d..22f54cd15 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -185,6 +185,9 @@ object Settings { ) } + val sbt013Version = "0.13.8" + val sbt10Version = "1.0.2" + lazy val plugin = javaScalaPluginShared ++ divertThingsPlugin ++ @@ -205,8 +208,8 @@ object Settings { scalaVersion := appConfiguration.value.provider.scalaProvider.version, // required with sbt 0.13.16-M1, to avoid cyclic references sbtVersion := { scalaBinaryVersion.value match { - case "2.10" => "0.13.8" - case "2.12" => "1.0.2" + case "2.10" => sbt013Version + case "2.12" => sbt10Version case _ => sbtVersion.value } }, 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-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala b/sbt-shared/src/main/scala-2.10/coursier/SbtCompatibility.scala similarity index 94% rename from sbt-coursier/src/main/scala-2.10/coursier/SbtCompatibility.scala rename to sbt-shared/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-shared/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-2.10/sbt/ModuleReportOps.scala b/sbt-shared/src/main/scala-2.10/sbt/ModuleReportOps.scala similarity index 100% rename from sbt-coursier/src/main/scala-2.10/sbt/ModuleReportOps.scala rename to sbt-shared/src/main/scala-2.10/sbt/ModuleReportOps.scala 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) +} diff --git a/sbt-coursier/src/main/scala-2.12/coursier/SbtCompatibility.scala b/sbt-shared/src/main/scala-2.12/coursier/SbtCompatibility.scala similarity index 100% rename from sbt-coursier/src/main/scala-2.12/coursier/SbtCompatibility.scala rename to sbt-shared/src/main/scala-2.12/coursier/SbtCompatibility.scala diff --git a/sbt-coursier/src/main/scala/coursier/FromSbt.scala b/sbt-shared/src/main/scala/coursier/FromSbt.scala similarity index 100% rename from sbt-coursier/src/main/scala/coursier/FromSbt.scala rename to sbt-shared/src/main/scala/coursier/FromSbt.scala diff --git a/sbt-coursier/src/main/scala/coursier/ToSbt.scala b/sbt-shared/src/main/scala/coursier/ToSbt.scala similarity index 96% rename from sbt-coursier/src/main/scala/coursier/ToSbt.scala rename to sbt-shared/src/main/scala/coursier/ToSbt.scala index 2c4db0c9e..24c3a16a8 100644 --- a/sbt-coursier/src/main/scala/coursier/ToSbt.scala +++ b/sbt-shared/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/scripts/travis.sh b/scripts/travis.sh index 3aba4d596..cbd51b664 100755 --- a/scripts/travis.sh +++ b/scripts/travis.sh @@ -80,7 +80,7 @@ runSbtCoursierTests() { } runSbtShadingTests() { - sbt ++$SCALA_VERSION coreJVM/publishLocal cache/publishLocal extra/publishLocal sbt-coursier/publishLocal "sbt-shading/scripted sbt-shading/*" + sbt ++$SCALA_VERSION coreJVM/publishLocal cache/publishLocal extra/publishLocal sbt-shared/publishLocal sbt-coursier/publishLocal "sbt-shading/scripted sbt-shading/*" if [ "$SCALA_VERSION" = "2.10" ]; then sbt ++$SCALA_VERSION "sbt-shading/scripted sbt-shading-0.13/*" fi