diff --git a/project/Settings.scala b/project/Settings.scala index 3dbf960fd..632978d07 100644 --- a/project/Settings.scala +++ b/project/Settings.scala @@ -178,11 +178,91 @@ object Settings { ) } + lazy val scripted100M6Workaround = { + + // see https://github.com/sbt/sbt/issues/3245#issuecomment-306045952 + + ScriptedPlugin.scripted := Def.inputTask { + + val args = ScriptedPlugin + .asInstanceOf[{ + def scriptedParser(f: File): complete.Parser[Seq[String]] + }] + .scriptedParser(sbtTestDirectory.value) + .parsed + + val prereq: Unit = scriptedDependencies.value + val scriptedTests = ScriptedPlugin.scriptedTests.value + + val testDir = sbtTestDirectory.value + val log = scriptedBufferLog.value + val args0 = args.toArray + val launcher = sbtLauncher.value + val opts = scriptedLaunchOpts.value.toArray + + val sbtv = sbtVersion.in(pluginCrossBuild).value + + try { + if(sbtv == "1.0.0-M6") + scriptedTests.asInstanceOf[{ + def run( + x1: File, + x2: Boolean, + x3: Array[String], + x4: File, + x5: Array[String], + x6: java.util.List[File] + ): Unit + }].run(testDir, log, args0, launcher, opts, new java.util.ArrayList) + else + scriptedTests.asInstanceOf[{ + def run( + x1: File, + x2: Boolean, + x3: Array[String], + x4: File, + x5: Array[String] + ): Unit + }].run(testDir, log, args0, launcher, opts) + } catch { + case e: java.lang.reflect.InvocationTargetException => + throw e.getCause + } + }.evaluated + } + lazy val plugin = javaScalaPluginShared ++ divertThingsPlugin ++ withScriptedTests ++ Seq( + sbtLauncher := { + + val rep = update + .value + .configuration(ScriptedPlugin.scriptedLaunchConf.name) + .getOrElse(sys.error(s"Configuration ${ScriptedPlugin.scriptedLaunchConf.name} not found")) + + val org = "org.scala-sbt" + val name = "sbt-launch" + + val (_, jar) = rep + .modules + .find { modRep => + modRep.module.organization == org && modRep.module.name == name + } + .getOrElse { + sys.error(s"Module $org:$name not found in configuration ${ScriptedPlugin.scriptedLaunchConf.name}") + } + .artifacts + .headOption + .getOrElse { + sys.error(s"No artifacts found for module $org:$name in configuration ${ScriptedPlugin.scriptedLaunchConf.name}") + } + + jar + }, + scripted100M6Workaround, scriptedLaunchOpts ++= Seq( "-Xmx1024M", "-Dplugin.version=" + version.value, @@ -199,7 +279,7 @@ object Settings { sbtVersion := { scalaBinaryVersion.value match { case "2.10" => "0.13.8" - case "2.12" => "1.0.0-M5" + case "2.12" => "1.0.0-M6" case _ => sbtVersion.value } }, diff --git a/sbt-coursier/src/main/scala/coursier/Tasks.scala b/sbt-coursier/src/main/scala/coursier/Tasks.scala index 70c7e6b78..6a3fdbd14 100644 --- a/sbt-coursier/src/main/scala/coursier/Tasks.scala +++ b/sbt-coursier/src/main/scala/coursier/Tasks.scala @@ -499,15 +499,20 @@ object Tasks { // Downloads are already parallel, no need to parallelize further anyway synchronized { - lazy val cm = coursierSbtClassifiersModule.value + val cm = coursierSbtClassifiersModule.value - lazy val projectName = thisProjectRef.value.project + val projectName = thisProjectRef.value.project + val baseConfigGraphs = coursierConfigGraphs.value + + val sv = scalaVersion.value + val sbv = scalaBinaryVersion.value + + val proj = coursierProject.value + val publications = coursierPublications.value + val fallbackDeps = coursierFallbackDependencies.value val (currentProject, fallbackDependencies, configGraphs) = if (sbtClassifiers) { - val sv = scalaVersion.value - val sbv = scalaBinaryVersion.value - val proj = FromSbt.project( cm.id, cm.modules, @@ -523,12 +528,8 @@ object Tasks { ) (proj, fallbackDeps, Vector(cm.configurations.map(_.name).toSet)) - } else { - val proj = coursierProject.value - val publications = coursierPublications.value - val fallbackDeps = coursierFallbackDependencies.value - (proj.copy(publications = publications), fallbackDeps, coursierConfigGraphs.value) - } + } else + (proj.copy(publications = publications), fallbackDeps, baseConfigGraphs) val interProjectDependencies = coursierInterProjectDependencies.value @@ -543,18 +544,19 @@ object Tasks { // are these always defined? (e.g. for Java only projects?) val so = scalaOrganization.value - val sv = scalaVersion.value - val sbv = scalaBinaryVersion.value val userForceVersions = dependencyOverrides.value.map( FromSbt.moduleVersion(_, sv, sbv) ).toMap + val sbtResolvers = coursierSbtResolvers.value + val defaultResolvers = coursierRecursiveResolvers.value + val resolvers = if (sbtClassifiers) - coursierSbtResolvers.value + sbtResolvers else - coursierRecursiveResolvers.value.distinct + defaultResolvers.distinct val parentProjectCache: ProjectCache = coursierParentProjectCache.value .get(resolvers) @@ -600,11 +602,11 @@ object Tasks { ) ++ sys.props val useSbtCredentials = coursierUseSbtCredentials.value + val sbtCreds = sbt.Keys.credentials.value val authenticationByHost = if (useSbtCredentials) - sbt.Keys.credentials - .value + sbtCreds .flatMap { case dc: sbt.DirectCredentials => List(dc) case fc: sbt.FileCredentials => @@ -862,11 +864,16 @@ object Tasks { val verbosityLevel = coursierVerbosity.value + val classifiersRes = coursierSbtClassifiersResolution.value + val mainRes = coursierResolutions.value + val res = if (withClassifiers && sbtClassifiers) - Seq(coursierSbtClassifiersResolution.value) + Seq(classifiersRes) else - coursierResolutions.value.values.toVector + mainRes.values.toVector + + val trClassifiers = transitiveClassifiers.value val classifiers = if (withClassifiers) @@ -874,7 +881,7 @@ object Tasks { if (sbtClassifiers) cm.classifiers else - transitiveClassifiers.value + trClassifiers } else None @@ -1058,13 +1065,16 @@ object Tasks { internalSbtScalaProvider.jars() ) - lazy val cm = coursierSbtClassifiersModule.value + val cm = coursierSbtClassifiersModule.value + + val sv = scalaVersion.value + val sbv = scalaBinaryVersion.value + + val proj = coursierProject.value + val publications = coursierPublications.value val currentProject = - if (sbtClassifiers) { - val sv = scalaVersion.value - val sbv = scalaBinaryVersion.value - + if (sbtClassifiers) FromSbt.project( cm.id, cm.modules, @@ -1072,22 +1082,21 @@ object Tasks { sv, sbv ) - } else { - val proj = coursierProject.value - val publications = coursierPublications.value + else proj.copy(publications = publications) - } val log = streams.value.log val verbosityLevel = coursierVerbosity.value + val classifiersRes = coursierSbtClassifiersResolution.value + val mainRes = coursierResolutions.value + val res = - if (withClassifiers && sbtClassifiers) { - val r = coursierSbtClassifiersResolution.value - Map(cm.configurations.map(c => c.name).toSet -> r) - } else - coursierResolutions.value + if (withClassifiers && sbtClassifiers) + Map(cm.configurations.map(c => c.name).toSet -> classifiersRes) + else + mainRes val configResolutions = res.flatMap { case (configs, r) => @@ -1128,13 +1137,15 @@ object Tasks { log.info(repr.split('\n').map(" " + _).mkString("\n")) } + val trClassifiers = transitiveClassifiers.value + val classifiers = if (withClassifiers) Some { if (sbtClassifiers) cm.classifiers else - transitiveClassifiers.value + trClassifiers } else None @@ -1218,12 +1229,15 @@ object Tasks { lazy val projectName = thisProjectRef.value.project - val currentProject = - if (sbtClassifiers) { - val cm = coursierSbtClassifiersModule.value - val sv = scalaVersion.value - val sbv = scalaBinaryVersion.value + val cm = coursierSbtClassifiersModule.value + val sv = scalaVersion.value + val sbv = scalaBinaryVersion.value + val proj = coursierProject.value + val publications = coursierPublications.value + + val currentProject = + if (sbtClassifiers) FromSbt.project( cm.id, cm.modules, @@ -1231,18 +1245,17 @@ object Tasks { sv, sbv ) - } else { - val proj = coursierProject.value - val publications = coursierPublications.value + else proj.copy(publications = publications) - } + + val classifiersRes = coursierSbtClassifiersResolution.value + val mainRes = coursierResolutions.value val resolutions = - if (sbtClassifiers) { - val r = coursierSbtClassifiersResolution.value - Map(currentProject.configurations.keySet -> r) - } else - coursierResolutions.value + if (sbtClassifiers) + Map(currentProject.configurations.keySet -> classifiersRes) + else + mainRes val config = configuration.value.name val configs = coursierConfigurations.value diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/build.sbt b/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/build.sbt index 6c0d86ed7..cedd2fa55 100644 --- a/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/build.sbt +++ b/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/build.sbt @@ -1,6 +1,6 @@ // for SbtExclusionRule with sbt 1.0 -import sbt.internal.librarymanagement._ +import Compatibility._ scalaVersion := "2.11.8" diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/project/src/main/scala-2.10/Compatibility.scala b/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/project/src/main/scala-2.10/Compatibility.scala new file mode 100644 index 000000000..19835e1be --- /dev/null +++ b/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/project/src/main/scala-2.10/Compatibility.scala @@ -0,0 +1 @@ +object Compatibility diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/project/src/main/scala-2.12/Compatibility.scala b/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/project/src/main/scala-2.12/Compatibility.scala new file mode 100644 index 000000000..53962be7a --- /dev/null +++ b/sbt-coursier/src/sbt-test/sbt-coursier/exclude-dependencies/project/src/main/scala-2.12/Compatibility.scala @@ -0,0 +1,5 @@ +object Compatibility { + + val SbtExclusionRule = sbt.ExclusionRule + +} diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/no-pom-artifact/build.sbt b/sbt-coursier/src/sbt-test/sbt-coursier/no-pom-artifact/build.sbt index 372da643b..274b6a675 100644 --- a/sbt-coursier/src/sbt-test/sbt-coursier/no-pom-artifact/build.sbt +++ b/sbt-coursier/src/sbt-test/sbt-coursier/no-pom-artifact/build.sbt @@ -3,6 +3,8 @@ lazy val noPomCheck = TaskKey[Unit]("noPomCheck") noPomCheck := { + val log = streams.value.log + val configReport = update.value .configuration("compile") .getOrElse { @@ -22,7 +24,7 @@ noPomCheck := { } for (a <- pomArtifacts) - streams.value.log.error(s"Found POM artifact $a") + log.error(s"Found POM artifact $a") assert(pomArtifacts.isEmpty) } diff --git a/sbt-coursier/src/sbt-test/sbt-coursier/publish-local-sources-javadoc-conf/build.sbt b/sbt-coursier/src/sbt-test/sbt-coursier/publish-local-sources-javadoc-conf/build.sbt index 0bae35eb6..83b642554 100644 --- a/sbt-coursier/src/sbt-test/sbt-coursier/publish-local-sources-javadoc-conf/build.sbt +++ b/sbt-coursier/src/sbt-test/sbt-coursier/publish-local-sources-javadoc-conf/build.sbt @@ -20,6 +20,8 @@ lazy val shared = Seq( scalaVersion := "2.11.8", confCheck := { + val log = streams.value.log + val updateReport = update.value val updateClassifiersReport = updateClassifiers.value @@ -41,12 +43,12 @@ lazy val shared = Seq( a } - streams.value.log.info( + log.info( s"Found ${artifacts.length} artifacts for config $config / classifier $classifier" + (if (useClassifiersReport) " in classifiers report" else "") ) for (a <- artifacts) - streams.value.log.info(" " + a) + log.info(" " + a) artifacts } diff --git a/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/build.sbt b/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/build.sbt index 2a1f71f12..ebf7f80c8 100644 --- a/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/build.sbt +++ b/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/build.sbt @@ -1,6 +1,6 @@ // for SbtExclusionRule with sbt 1.0 -import sbt.internal.librarymanagement._ +import Compatibility._ enablePlugins(coursier.ShadingPlugin) shadingNamespace := "test.shaded" diff --git a/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/project/src/main/scala-2.10/Compatibility.scala b/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/project/src/main/scala-2.10/Compatibility.scala new file mode 100644 index 000000000..19835e1be --- /dev/null +++ b/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/project/src/main/scala-2.10/Compatibility.scala @@ -0,0 +1 @@ +object Compatibility diff --git a/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/project/src/main/scala-2.12/Compatibility.scala b/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/project/src/main/scala-2.12/Compatibility.scala new file mode 100644 index 000000000..53962be7a --- /dev/null +++ b/sbt-shading/src/sbt-test/sbt-shading/exclude-dependencies/project/src/main/scala-2.12/Compatibility.scala @@ -0,0 +1,5 @@ +object Compatibility { + + val SbtExclusionRule = sbt.ExclusionRule + +} diff --git a/sbt-shading/src/sbt-test/sbt-shading/shade-namespace/build.sbt b/sbt-shading/src/sbt-test/sbt-shading/shade-namespace/build.sbt index a68e32723..167d55b76 100644 --- a/sbt-shading/src/sbt-test/sbt-shading/shade-namespace/build.sbt +++ b/sbt-shading/src/sbt-test/sbt-shading/shade-namespace/build.sbt @@ -19,9 +19,9 @@ lazy val checkToShadeClasses = TaskKey[Unit]("check-to-shade-classes") checkToShadeClasses := { val toShadeClasses0 = toShadeClasses.in(Shading).value + val log = streams.value.log if (toShadeClasses0.nonEmpty) { - val log = streams.value.log log.error(s"Found ${toShadeClasses0.length} classes to be explicitly shaded") for (name <- toShadeClasses0) log.error(" " + name)