private def splitConfigurationsToDifferentSourceSets()

in extractor-legacy-0.13/src/main/scala/org/jetbrains/sbt/extractors/DependenciesExtractor.scala [130:155]


  private def splitConfigurationsToDifferentSourceSets(configurations: Seq[Configuration]): Dependencies[Configuration] = {
    val cs = mergeAllTestConfigurations(configurations)
    val (prodConfigs, testConfigs) = {
      if (Seq(Configuration.Compile, Configuration.Test, Configuration.Runtime).forall(cs.contains)) { // compile configuration
        (Seq(Configuration.Compile), Seq(Configuration.Compile))
      } else {
        Seq(
          // 1. The downside of this logic is that if cs contains only some custom source configuration (not one that is available in sbt by default),
          // then prodConfigs will be empty. It is fixed in #updateProductionConfigs.
          // Mapping custom source configurations to Compile, couldn't be done at the same place as
          // #mergeAllTestConfigurations, because then Compile would be converted into Provided and it is not the purpose.
          // 2. These 3 conditions are also suitable for -internal configurations because when e.g. compile-internal configuration
          // is used cs contains only compile configuration and this will cause the dependency to be added to the production module
          // with the provided scope
          (cs.contains(Configuration.Test), Nil, Seq(Configuration.Compile)),
          (cs.contains(Configuration.Compile), Seq(Configuration.Provided), Nil),
          (cs.contains(Configuration.Runtime), Seq(Configuration.Runtime), Nil)
        ).foldLeft((Seq.empty[Configuration], Seq.empty[Configuration])) { case((productionSoFar, testSoFar), (condition, productionUpdate, testUpdate)) =>
          if (condition) (productionSoFar ++ productionUpdate, testSoFar ++ testUpdate)
          else (productionSoFar, testSoFar)
        }
      }
    }
    val updatedProdConfigs = updateProductionConfigs(prodConfigs, cs)
    Dependencies(updatedProdConfigs, testConfigs)
  }