diff --git a/README.md b/README.md index 2aecb9bbd..b133b4c7e 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,12 @@ Add an import for coursier, import coursier._ ``` + + + + + + To resolve dependencies, first create a `Resolution` case class with your dependencies in it, ```scala val start = Resolution( @@ -367,6 +373,10 @@ In the code below, we'll assume some imports are around, import coursier._ ``` + + + + Resolving dependencies involves create an initial resolution state, with all the initial dependencies in it, like ```scala val start = Resolution( @@ -399,7 +409,7 @@ scala> val repositories = Seq( | Cache.ivy2Local, | MavenRepository("https://repo1.maven.org/maven2") | ) -repositories: Seq[coursier.core.Repository] = List(IvyRepository(file:/Users/alexandre/.ivy2/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext],None,None,Map(),true,true,true,true), MavenRepository(https://repo1.maven.org/maven2,None,false)) +repositories: Seq[coursier.core.Repository] = List(IvyRepository(file://${user.home}/.ivy2/local/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext],None,None,Map(),true,true,true,true), MavenRepository(https://repo1.maven.org/maven2,None,false)) ``` The first one, `Cache.ivy2Local`, is defined in `coursier.Cache`, itself from the `coursier-cache` module that we added above. As we can see, it is an `IvyRepository`, picking things under `~/.ivy2/local`. An `IvyRepository` diff --git a/doc/README.md b/doc/README.md index 23a04eb2e..31ba4bb18 100644 --- a/doc/README.md +++ b/doc/README.md @@ -103,10 +103,38 @@ libraryDependencies ++= Seq( ``` Add an import for coursier, -```tut:silent +```scala import coursier._ ``` +```tut:invisible +import coursier.{ Cache => _, _ } +``` + +```tut:invisible +object Cache { + val ivy2LocalIsIvy = coursier.Cache.ivy2Local match { + case _: coursier.ivy.IvyRepository => true + case _ => false + } + + assert(ivy2LocalIsIvy) + + // The goal of this is to make the printed ivy2Local below more anonymous, + // with literally ${user.home} in it rather than the current home dir. + // ${user.home} could have been used in the definition of ivy2Local itself, + // but it would then have required properties, which would have cluttered + // output here. + + val ivy2Local = coursier.Cache.ivy2Local.copy( + pattern = coursier.Cache.ivy2Local.pattern.replace("file:" + sys.props("user.home"), "file://${user.home}") + ) + + def fetch() = coursier.Cache.fetch() + def file(artifact: Artifact) = coursier.Cache.file(artifact) +} +``` + To resolve dependencies, first create a `Resolution` case class with your dependencies in it, ```tut:silent val start = Resolution( @@ -365,10 +393,15 @@ these input metadata. It uses `scalaz.concurrent.Task` as a `Monad` to wrap them It caches all of these (metadata and artifacts) on disk, and validates checksums too. In the code below, we'll assume some imports are around, -```tut:silent +```scala import coursier._ ``` +```tut:invisible +import coursier.{ Cache => _, _ } +``` + + Resolving dependencies involves create an initial resolution state, with all the initial dependencies in it, like ```tut:silent val start = Resolution(