Permalink
Browse files

Merge pull request #933 from coursier/develop

Various things
  • Loading branch information...
alexarchambault committed Oct 10, 2018
2 parents 4909c5e + 3101909 commit 8c20ed54bf8df66bb7dc26a05d78667fe07f7072
Showing with 831 additions and 494 deletions.
  1. +21 −3 build.sbt
  2. +3 −0 modules/cache/jvm/src/main/scala/coursier/util/PlatformTask.scala
  3. +5 −0 modules/cache/jvm/src/main/scala/coursier/util/Schedulable.scala
  4. +1 −1 modules/cli/src/main/scala-2.12/BUILD
  5. +1 −1 modules/cli/src/main/scala-2.12/coursier/cli/Helper.scala
  6. +2 −1 modules/cli/src/main/scala-2.12/coursier/cli/options/CommonOptions.scala
  7. +2 −1 modules/cli/src/main/scala-2.12/coursier/cli/options/IsolatedLoaderOptions.scala
  8. +1 −1 modules/cli/src/main/scala-2.12/coursier/cli/util/JsonReport.scala
  9. +3 −3 modules/core/jvm/src/main/scala/coursier/maven/WritePom.scala
  10. +42 −9 modules/core/shared/src/main/scala/coursier/core/Definitions.scala
  11. +10 −10 modules/core/shared/src/main/scala/coursier/core/Orders.scala
  12. +5 −4 modules/core/shared/src/main/scala/coursier/core/Parse.scala
  13. +58 −53 modules/core/shared/src/main/scala/coursier/core/Resolution.scala
  14. +3 −3 modules/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala
  15. +23 −15 modules/core/shared/src/main/scala/coursier/ivy/IvyXml.scala
  16. +6 −6 modules/core/shared/src/main/scala/coursier/maven/MavenRepository.scala
  17. +10 −8 modules/core/shared/src/main/scala/coursier/maven/Pom.scala
  18. +1 −1 modules/core/shared/src/main/scala/coursier/package.scala
  19. +9 −9 modules/core/shared/src/main/scala/coursier/util/Config.scala
  20. +3 −3 modules/core/shared/src/main/scala/coursier/util/Parse.scala
  21. +4 −4 modules/core/shared/src/main/scala/coursier/util/Print.scala
  22. +3 −0 modules/interop/cats/js/src/main/scala/coursier/interop/PlatformCatsImplicits.scala
  23. +42 −0 modules/interop/cats/jvm/src/main/scala/coursier/interop/PlatformCatsImplicits.scala
  24. +55 −0 modules/interop/cats/jvm/src/test/scala/coursier/interop/CatsTests.scala
  25. +27 −0 modules/interop/cats/shared/src/main/scala/coursier/interop/cats.scala
  26. +1 −1 modules/{ → interop}/scalaz/BUILD
  27. 0 modules/{ → interop}/scalaz/js/src/main/scala/coursier/interop/PlatformScalazImplicits.scala
  28. +4 −0 modules/{ → interop}/scalaz/jvm/src/main/scala/coursier/interop/PlatformScalazImplicits.scala
  29. +59 −0 modules/interop/scalaz/jvm/src/test/scala/coursier/interop/ScalazTests.scala
  30. 0 modules/{ → interop}/scalaz/shared/src/main/scala/coursier/interop/scalaz.scala
  31. +1 −1 modules/tests/js/src/test/scala/coursier/test/compatibility/package.scala
  32. +5 −2 modules/tests/jvm/src/it/scala/coursier/test/DirectoryListingTests.scala
  33. +5 −3 modules/tests/jvm/src/it/scala/coursier/test/IvyLocalTests.scala
  34. +4 −4 modules/tests/jvm/src/test/scala/coursier/Platform.scala
  35. +15 −12 modules/tests/jvm/src/test/scala/coursier/test/IvyTests.scala
  36. +5 −2 modules/tests/jvm/src/test/scala/coursier/test/MavenTests.scala
  37. +24 −14 modules/tests/jvm/src/test/scala/coursier/test/ResolutionProcessTests.scala
  38. +13 −9 modules/tests/jvm/src/test/scala/coursier/test/compatibility/package.scala
  39. +77 −250 modules/tests/shared/src/test/scala/coursier/test/CentralTests.scala
  40. +6 −6 modules/tests/shared/src/test/scala/coursier/test/ParseTests.scala
  41. +4 −4 modules/tests/shared/src/test/scala/coursier/test/PomParsingTests.scala
  42. +36 −36 modules/tests/shared/src/test/scala/coursier/test/ResolutionTests.scala
  43. +190 −0 modules/tests/shared/src/test/scala/coursier/test/TestRunner.scala
  44. +8 −8 modules/tests/shared/src/test/scala/coursier/test/package.scala
  45. +22 −0 modules/tests/shared/src/test/scala/coursier/test/util/ToFuture.scala
  46. +6 −4 modules/tests/shared/src/test/scala/coursier/util/PrintTests.scala
  47. +2 −2 modules/web/src/main/scala/coursier/web/App.scala
  48. +1 −0 project/CrossDeps.scala
  49. +3 −0 project/Settings.scala
View
@@ -37,7 +37,7 @@ lazy val coreJvm = core.jvm
lazy val coreJs = core.js
lazy val tests = crossProject("tests")(JSPlatform, JVMPlatform)
.dependsOn(core, cache % Test, scalaz)
.dependsOn(core, cache % Test)
.jsSettings(
scalaJSStage.in(Global) := FastOptStage,
testOptions := testOptions.dependsOn(runNpmInstallIfNeeded).value
@@ -98,8 +98,8 @@ lazy val cache = crossProject("cache")(JSPlatform, JVMPlatform)
lazy val cacheJvm = cache.jvm
lazy val cacheJs = cache.js
lazy val scalaz = crossProject("scalaz")(JSPlatform, JVMPlatform)
.dependsOn(cache)
lazy val scalaz = crossProject("interop", "scalaz")(JSPlatform, JVMPlatform)
.dependsOn(cache, tests % "test->test")
.jvmSettings(
libs += Deps.scalazConcurrent
)
@@ -109,13 +109,28 @@ lazy val scalaz = crossProject("scalaz")(JSPlatform, JVMPlatform)
.settings(
name := "scalaz-interop",
shared,
utest,
Mima.previousArtifacts,
coursierPrefix
)
lazy val scalazJvm = scalaz.jvm
lazy val scalazJs = scalaz.js
lazy val cats = crossProject("interop", "cats")(JSPlatform, JVMPlatform)
.dependsOn(cache, tests % "test->test")
.settings(
name := "cats-interop",
shared,
utest,
Mima.previousArtifacts,
coursierPrefix,
libs += CrossDeps.catsEffect.value
)
lazy val catsJvm = cats.jvm
lazy val catsJs = cats.js
lazy val bootstrap = project("bootstrap")
.settings(
pureJava,
@@ -257,6 +272,7 @@ lazy val jvm = project("jvm")
paths,
cacheJvm,
scalazJvm,
catsJvm,
bootstrap,
extra,
cli,
@@ -287,6 +303,8 @@ lazy val js = project("js")
lazy val coursier = project("coursier")
.in(root)
.aggregate(
catsJvm,
catsJs,
coreJvm,
coreJs,
testsJvm,
@@ -19,6 +19,9 @@ abstract class PlatformTask { self =>
implicit val schedulable: Schedulable[Task] =
new TaskGather with Schedulable[Task] {
def delay[A](a: => A) = Task.delay(a)
def handle[A](a: Task[A])(f: PartialFunction[Throwable, A]) =
a.handle(f)
def schedule[A](pool: ExecutorService)(f: => A) = self.schedule(pool)(f)
}
@@ -3,11 +3,16 @@ package coursier.util
import java.util.concurrent.{ExecutorService, Executors, ThreadFactory}
trait Schedulable[F[_]] extends Gather[F] {
def delay[A](a: => A): F[A]
def handle[A](a: F[A])(f: PartialFunction[Throwable, A]): F[A]
def schedule[A](pool: ExecutorService)(f: => A): F[A]
}
object Schedulable {
def apply[F[_]](implicit schedulable: Schedulable[F]): Schedulable[F] =
schedulable
lazy val defaultThreadPool =
fixedThreadPool(4 max Runtime.getRuntime.availableProcessors())
@@ -8,7 +8,7 @@ scala_library(
"extra/src/main/scala/coursier:fallback-deps-repo",
"extra/src/main/scala/coursier/extra:extra",
"extra/src/main/scala-2.12/coursier/extra:native",
"scalaz:scalaz-interop",
"interop/scalaz:scalaz-interop",
":util",
],
sources = globs(
@@ -261,7 +261,7 @@ class Helper(
.toMap
}
val moduleReq = ModuleRequirements(globalExcludes, localExcludeMap, defaultConfiguration)
val moduleReq = ModuleRequirements(globalExcludes, localExcludeMap, defaultConfiguration0)
val (modVerCfgErrors: Seq[String], normalDepsWithExtraParams: Seq[(Dependency, Map[String, String])]) =
Parse.moduleVersionConfigs(otherRawDependencies, moduleReq, transitive=true, scalaVersion)
@@ -1,7 +1,7 @@
package coursier.cli.options
import caseapp.{ExtraName => Short, HelpMessage => Help, ValueDescription => Value, _}
import coursier.core.{Classifier, ResolutionProcess}
import coursier.core.{Classifier, Configuration, ResolutionProcess}
final case class CommonOptions(
@Help("Keep optional dependencies (Maven)")
@@ -109,6 +109,7 @@ final case class CommonOptions(
) {
val verbosityLevel = Tag.unwrap(verbose) - (if (quiet) 1 else 0)
lazy val classifier0 = classifier.flatMap(_.split(',')).filter(_.nonEmpty).map(Classifier(_)).toSet
val defaultConfiguration0 = Configuration(defaultConfiguration)
}
object CommonOptions {
@@ -1,6 +1,7 @@
package coursier.cli.options
import caseapp.{ExtraName => Short, HelpMessage => Help, ValueDescription => Value, _}
import coursier.core.Configuration
import coursier.{Attributes, Dependency}
import coursier.util.Parse
@@ -67,7 +68,7 @@ final case class IsolatedLoaderOptions(
Dependency(
mod,
ver,
configuration = "runtime",
configuration = Configuration.runtime,
attributes = Attributes()
)
}
@@ -182,7 +182,7 @@ final case class JsonElem(dep: Dependency,
.filterNot(dependencies.map(_.moduleVersion).toSet).map {
case (mod, ver) =>
JsonElem(
Dependency(mod, ver, "", Set.empty, Attributes.empty, optional = false, transitive = false),
Dependency(mod, ver, Configuration.empty, Set.empty, Attributes.empty, optional = false, transitive = false),
artifacts,
jsonPrintRequirement,
resolution,
@@ -1,12 +1,12 @@
package coursier.maven
import coursier.core.{ Dependency, Project }
import coursier.core.{Configuration, Dependency, Project}
object WritePom {
def project(proj: Project, packaging: Option[String]) = {
def dependencyNode(config: String, dep: Dependency) = {
def dependencyNode(config: Configuration, dep: Dependency) = {
<dependency>
<groupId>{dep.module.organization}</groupId>
<artifactId>{dep.module.name}</artifactId>
@@ -20,7 +20,7 @@ object WritePom {
if (config.isEmpty)
Nil
else
Seq(<scope>{config}</scope>)
Seq(<scope>{config.value}</scope>)
}
</dependency>
}
@@ -66,7 +66,7 @@ final case class Module(
final case class Dependency(
module: Module,
version: String,
configuration: String,
configuration: Configuration,
exclusions: Set[(Organization, ModuleName)],
// Maven-specific
@@ -158,6 +158,40 @@ object Extension {
val empty = Extension("")
}
final case class Configuration(value: String) extends AnyVal {
def isEmpty: Boolean =
value.isEmpty
def nonEmpty: Boolean =
value.nonEmpty
def -->(target: Configuration): Configuration =
Configuration(s"$value->${target.value}")
def map(f: String => String): Configuration =
Configuration(f(value))
}
object Configuration {
implicit val ordering: Ordering[Configuration] =
Ordering[String].on(_.value)
val empty = Configuration("")
val compile = Configuration("compile")
val runtime = Configuration("runtime")
val test = Configuration("test")
val default = Configuration("default")
val defaultCompile = Configuration("default(compile)")
val provided = Configuration("provided")
val `import` = Configuration("import")
val optional = Configuration("optional")
val all = Configuration("*")
def join(confs: Configuration*): Configuration =
Configuration(confs.map(_.value).mkString(";"))
}
// Maven-specific
final case class Attributes(
`type`: Type,
@@ -192,13 +226,13 @@ final case class Project(
module: Module,
version: String,
// First String is configuration (scope for Maven)
dependencies: Seq[(String, Dependency)],
dependencies: Seq[(Configuration, Dependency)],
// For Maven, this is the standard scopes as an Ivy configuration
configurations: Map[String, Seq[String]],
configurations: Map[Configuration, Seq[Configuration]],
// Maven-specific
parent: Option[(Module, String)],
dependencyManagement: Seq[(String, Dependency)],
dependencyManagement: Seq[(Configuration, Dependency)],
properties: Seq[(String, String)],
profiles: Seq[Profile],
versions: Option[Versions],
@@ -212,16 +246,15 @@ final case class Project(
*/
actualVersionOpt: Option[String],
// First String is configuration
publications: Seq[(String, Publication)],
publications: Seq[(Configuration, Publication)],
// Extra infos, not used during resolution
info: Info
) {
lazy val moduleVersion = (module, version)
/** All configurations that each configuration extends, including the ones it extends transitively */
lazy val allConfigurations: Map[String, Set[String]] =
lazy val allConfigurations: Map[Configuration, Set[Configuration]] =
Orders.allConfigurations(configurations)
/**
@@ -256,8 +289,8 @@ final case class Profile(
id: String,
activeByDefault: Option[Boolean],
activation: Activation,
dependencies: Seq[(String, Dependency)],
dependencyManagement: Seq[(String, Dependency)],
dependencies: Seq[(Configuration, Dependency)],
dependencyManagement: Seq[(Configuration, Dependency)],
properties: Map[String, String]
)
@@ -9,9 +9,9 @@ object Orders {
}
/** All configurations that each configuration extends, including the ones it extends transitively */
def allConfigurations(configurations: Map[String, Seq[String]]): Map[String, Set[String]] = {
def allParents(config: String): Set[String] = {
def helper(configs: Set[String], acc: Set[String]): Set[String] =
def allConfigurations(configurations: Map[Configuration, Seq[Configuration]]): Map[Configuration, Set[Configuration]] = {
def allParents(config: Configuration): Set[Configuration] = {
def helper(configs: Set[Configuration], acc: Set[Configuration]): Set[Configuration] =
if (configs.isEmpty)
acc
else if (configs.exists(acc))
@@ -39,11 +39,11 @@ object Orders {
*
* @param configurations: for each configuration, the configurations it directly extends.
*/
def configurationPartialOrder(configurations: Map[String, Seq[String]]): PartialOrdering[String] =
new PartialOrdering[String] {
def configurationPartialOrder(configurations: Map[Configuration, Seq[Configuration]]): PartialOrdering[Configuration] =
new PartialOrdering[Configuration] {
val allParentsMap = allConfigurations(configurations)
def tryCompare(x: String, y: String) =
def tryCompare(x: Configuration, y: Configuration) =
if (x == y)
Some(0)
else if (allParentsMap.get(x).exists(_(y)))
@@ -121,7 +121,7 @@ object Orders {
}
}
private def fallbackConfigIfNecessary(dep: Dependency, configs: Set[String]): Dependency =
private def fallbackConfigIfNecessary(dep: Dependency, configs: Set[Configuration]): Dependency =
Parse.withFallbackConfig(dep.configuration) match {
case Some((main, fallback)) =>
val config0 =
@@ -143,7 +143,7 @@ object Orders {
*/
def minDependenciesUnsafe(
dependencies: Set[Dependency],
configs: Map[String, Seq[String]]
configs: Map[Configuration, Seq[Configuration]]
): Set[Dependency] = {
val availableConfigs = configs.keySet
val groupedDependencies = dependencies
@@ -176,10 +176,10 @@ object Orders {
*/
def minDependencies(
dependencies: Set[Dependency],
configs: ((Module, String)) => Map[String, Seq[String]]
configs: ((Module, String)) => Map[Configuration, Seq[Configuration]]
): Set[Dependency] = {
dependencies
.groupBy(_.copy(configuration = "", exclusions = Set.empty, optional = false))
.groupBy(_.copy(configuration = Configuration.empty, exclusions = Set.empty, optional = false))
.mapValues(deps => minDependenciesUnsafe(deps, configs(deps.head.moduleVersion)))
.valuesIterator
.fold(Set.empty)(_ ++ _)
@@ -93,12 +93,13 @@ object Parse {
"^" + noPar + quote("(") + noPar + quote(")") + "$"
}.r
def withFallbackConfig(config: String): Option[(String, String)] =
Parse.fallbackConfigRegex.findAllMatchIn(config).toSeq match {
// TODO Make that a method of Configuration?
def withFallbackConfig(config: Configuration): Option[(Configuration, Configuration)] =
Parse.fallbackConfigRegex.findAllMatchIn(config.value).toSeq match {
case Seq(m) =>
assert(m.groupCount == 2)
val main = config.substring(m.start(1), m.end(1))
val fallback = config.substring(m.start(2), m.end(2))
val main = Configuration(config.value.substring(m.start(1), m.end(1)))
val fallback = Configuration(config.value.substring(m.start(2), m.end(2)))
Some((main, fallback))
case _ =>
None
Oops, something went wrong.

0 comments on commit 8c20ed5

Please sign in to comment.