Make the printed ivy2Local in README look more anonymous

This commit is contained in:
Alexandre Archambault 2016-02-21 20:22:48 +01:00
parent 1a443b3758
commit 989c52055b
2 changed files with 46 additions and 3 deletions

View File

@ -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`

View File

@ -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(