From 594eb47bc59a324390f8f8293d7ae895e9939318 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Mon, 29 Oct 2018 11:30:34 +0100 Subject: [PATCH] Don't force scala version if autoScalaLibrary is false --- .../src/main/scala/coursier/Tasks.scala | 4 +++- .../auto-scala-library/build.sbt | 20 +++++++++++++++++++ .../auto-scala-library/project/plugins.sbt | 11 ++++++++++ .../auto-scala-library/test | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/build.sbt create mode 100644 modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/project/plugins.sbt create mode 100644 modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/test diff --git a/modules/sbt-coursier/src/main/scala/coursier/Tasks.scala b/modules/sbt-coursier/src/main/scala/coursier/Tasks.scala index 19d191015..dd58a2b98 100644 --- a/modules/sbt-coursier/src/main/scala/coursier/Tasks.scala +++ b/modules/sbt-coursier/src/main/scala/coursier/Tasks.scala @@ -814,6 +814,8 @@ object Tasks { val (currentProject, fallbackDependencies, configGraphs) = currentProjectTask.value + val autoScalaLib = autoScalaLibrary.value + val resolvers = resolversTask.value // TODO Warn about possible duplicated modules from source repositories? @@ -909,7 +911,7 @@ object Tasks { forceVersions = // order matters here userForceVersions ++ - (if (configs("compile") || configs("scala-tool")) forcedScalaModules(so, sv) else Map()) ++ + (if (autoScalaLib && (configs("compile") || configs("scala-tool"))) forcedScalaModules(so, sv) else Map()) ++ interProjectDependencies.map(_.moduleVersion), projectCache = parentProjectCache, mapDependencies = if (typelevel && (configs("compile") || configs("scala-tool"))) typelevelOrgSwap else None diff --git a/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/build.sbt b/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/build.sbt new file mode 100644 index 000000000..20969e7e5 --- /dev/null +++ b/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/build.sbt @@ -0,0 +1,20 @@ +autoScalaLibrary := false +libraryDependencies += "com.chuusai" % "shapeless_2.12" % "2.3.2" + +val checkScalaLibrary = TaskKey[Unit]("checkScalaLibrary") + +checkScalaLibrary := { + val scalaLibsJars = managedClasspath + .in(Compile) + .value + .map(_.data.getName) + .filter(_.startsWith("scala-library")) + .sorted + val expectedScalaLibsJars = Seq( + "scala-library-2.12.0.jar" + ) + assert( + scalaLibsJars == expectedScalaLibsJars, + s"$scalaLibsJars != $expectedScalaLibsJars" + ) +} diff --git a/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/project/plugins.sbt b/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/project/plugins.sbt new file mode 100644 index 000000000..152225a9e --- /dev/null +++ b/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/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/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/test b/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/test new file mode 100644 index 000000000..f56f5a75e --- /dev/null +++ b/modules/sbt-coursier/src/sbt-test/sbt-coursier-group-1/auto-scala-library/test @@ -0,0 +1 @@ +> checkScalaLibrary