From 5cce074b83e482a9109124f127c442ed6025d81e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 17 Jun 2020 19:37:26 -0400 Subject: [PATCH] Fixes missingOk under Coursier Fixes https://github.com/sbt/sbt/issues/4707 Ref https://github.com/coursier/sbt-coursier/pull/212 --- .../scala/sbt/coursierint/LMCoursier.scala | 58 +++++++++++++++++++ .../dependency-management/missingok/build.sbt | 40 +++++++++++++ .../dependency-management/missingok/test | 1 + 3 files changed, 99 insertions(+) create mode 100644 sbt/src/sbt-test/dependency-management/missingok/build.sbt create mode 100644 sbt/src/sbt-test/dependency-management/missingok/test diff --git a/main/src/main/scala/sbt/coursierint/LMCoursier.scala b/main/src/main/scala/sbt/coursierint/LMCoursier.scala index 1bbbd126d..5c4b950f9 100644 --- a/main/src/main/scala/sbt/coursierint/LMCoursier.scala +++ b/main/src/main/scala/sbt/coursierint/LMCoursier.scala @@ -68,6 +68,55 @@ object LMCoursier { strict: Option[CStrict], depsOverrides: Seq[ModuleID], log: Logger + ): CoursierConfiguration = + coursierConfiguration( + rs, + interProjectDependencies, + extraProjects, + fallbackDeps, + appConfig, + classifiers, + profiles, + scalaOrg, + scalaVer, + scalaBinaryVer, + autoScalaLib, + scalaModInfo, + excludeDeps, + credentials, + createLogger, + cacheDirectory, + reconciliation, + ivyHome, + strict, + depsOverrides, + None, + log + ) + + def coursierConfiguration( + rs: Seq[Resolver], + interProjectDependencies: Seq[CProject], + extraProjects: Seq[CProject], + fallbackDeps: Seq[FallbackDependency], + appConfig: AppConfiguration, + classifiers: Option[Seq[Classifier]], + profiles: Set[String], + scalaOrg: String, + scalaVer: String, + scalaBinaryVer: String, + autoScalaLib: Boolean, + scalaModInfo: Option[ScalaModuleInfo], + excludeDeps: Seq[InclExclRule], + credentials: Seq[Credentials], + createLogger: Option[CacheLogger], + cacheDirectory: File, + reconciliation: Seq[(ModuleMatchers, Reconciliation)], + ivyHome: Option[File], + strict: Option[CStrict], + depsOverrides: Seq[ModuleID], + updateConfig: Option[UpdateConfiguration], + log: Logger ): CoursierConfiguration = { val coursierExcludeDeps = Inputs .exclusions( @@ -92,6 +141,10 @@ object LMCoursier { val userForceVersions = Inputs.forceVersions(depsOverrides, scalaVer, scalaBinaryVer) Classpaths.warnResolversConflict(rs, log) Classpaths.errorInsecureProtocol(rs, log) + val missingOk = updateConfig match { + case Some(uc) => uc.missingOk + case _ => false + } CoursierConfiguration() .withResolvers(rs.toVector) .withInterProjectDependencies(interProjectDependencies.toVector) @@ -115,6 +168,7 @@ object LMCoursier { .withIvyHome(ivyHome) .withStrict(strict) .withForceVersions(userForceVersions.toVector) + .withMissingOk(missingOk) } def coursierConfigurationTask: Def.Initialize[Task[CoursierConfiguration]] = Def.task { @@ -139,6 +193,7 @@ object LMCoursier { ivyPaths.value.ivyHome, CoursierInputsTasks.strictTask.value, dependencyOverrides.value, + Some(updateConfiguration.value), streams.value.log ) } @@ -165,6 +220,7 @@ object LMCoursier { ivyPaths.value.ivyHome, CoursierInputsTasks.strictTask.value, dependencyOverrides.value, + Some(updateConfiguration.value), streams.value.log ) } @@ -191,6 +247,7 @@ object LMCoursier { ivyPaths.value.ivyHome, CoursierInputsTasks.strictTask.value, dependencyOverrides.value, + Some(updateConfiguration.value), streams.value.log ) } @@ -217,6 +274,7 @@ object LMCoursier { ivyPaths.value.ivyHome, CoursierInputsTasks.strictTask.value, dependencyOverrides.value, + Some(updateConfiguration.value), streams.value.log ) } diff --git a/sbt/src/sbt-test/dependency-management/missingok/build.sbt b/sbt/src/sbt-test/dependency-management/missingok/build.sbt new file mode 100644 index 000000000..51257fd6e --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/missingok/build.sbt @@ -0,0 +1,40 @@ +ThisBuild / scalaVersion := "2.13.2" +libraryDependencies ++= Seq( + "com.chuusai" %% "shapeless" % "2.3.3", + // non-existing + "org.webjars" % "npm" % "0.0.99" +) +updateConfiguration := updateConfiguration.value.withMissingOk(true) + +lazy val check = taskKey[Unit]("") + +check := { + val updateReport = update.value + val updateClassifiersReport = updateClassifiers.value + + val compileReport = updateReport + .configuration(Compile) + .getOrElse { + sys.error("Compile configuration not found in update report") + } + + val compileClassifiersReport = updateClassifiersReport + .configuration(Compile) + .getOrElse { + sys.error("Compile configuration not found in update classifiers report") + } + + val shapelessModule = compileReport + .modules + .find(_.module.name == "shapeless_2.13") + .getOrElse { + sys.error(s"shapeless module not found in ${compileReport.modules.map(_.module)}") + } + + val shapelessClassifiersModule = compileClassifiersReport + .modules + .find(_.module.name == "shapeless_2.13") + .getOrElse { + sys.error(s"shapeless module not found in ${compileClassifiersReport.modules.map(_.module)}") + } +} diff --git a/sbt/src/sbt-test/dependency-management/missingok/test b/sbt/src/sbt-test/dependency-management/missingok/test new file mode 100644 index 000000000..15675b169 --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/missingok/test @@ -0,0 +1 @@ +> check