From ad43b73883cbd3949f47c3f3a53c73ad9d72a680 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Sun, 21 Feb 2016 20:22:48 +0100 Subject: [PATCH 1/4] Really update Jupyter Scala mention --- README.md | 5 +++-- doc/README.md | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 16ac5e5dd..beb92368a 100644 --- a/README.md +++ b/README.md @@ -571,8 +571,9 @@ on the [Gitter channel](https://gitter.im/alexarchambault/coursier). - [Lars Hupel](https://github.com/larsrh/)'s [libisabelle](https://github.com/larsrh/libisabelle) fetches some of its requirements via coursier, -- [jupyter-scala](https://github.com/alexarchambault/jupyter-scala) should soon allow -to add dependencies in its sessions with coursier (initial motivation for writing coursier), +- [jupyter-scala](https://github.com/alexarchambault/jupyter-scala) is launched +and allows to add dependencies in its sessions with coursier (initial motivation +for writing coursier), - Your project here :-) diff --git a/doc/README.md b/doc/README.md index 2355c775b..a300adc1a 100644 --- a/doc/README.md +++ b/doc/README.md @@ -572,8 +572,9 @@ on the [Gitter channel](https://gitter.im/alexarchambault/coursier). - [Lars Hupel](https://github.com/larsrh/)'s [libisabelle](https://github.com/larsrh/libisabelle) fetches some of its requirements via coursier, -- [jupyter-scala](https://github.com/alexarchambault/jupyter-scala) should soon allow -to add dependencies in its sessions with coursier (initial motivation for writing coursier), +- [jupyter-scala](https://github.com/alexarchambault/jupyter-scala) is launched +and allows to add dependencies in its sessions with coursier (initial motivation +for writing coursier), - Your project here :-) From 1a443b375812d86486fa5edca2ad46fb00a1d763 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Sun, 21 Feb 2016 20:22:48 +0100 Subject: [PATCH 2/4] Really add line about Apache Toree --- README.md | 2 ++ doc/README.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index beb92368a..2aecb9bbd 100644 --- a/README.md +++ b/README.md @@ -574,6 +574,8 @@ some of its requirements via coursier, - [jupyter-scala](https://github.com/alexarchambault/jupyter-scala) is launched and allows to add dependencies in its sessions with coursier (initial motivation for writing coursier), +- [Apache Toree](https://github.com/apache/incubator-toree) - formerly known as [spark-kernel](https://github.com/ibm-et/spark-kernel), is now using coursier to +add dependencies on-the-fly ([#4](https://github.com/apache/incubator-toree/pull/4)), - Your project here :-) diff --git a/doc/README.md b/doc/README.md index a300adc1a..23a04eb2e 100644 --- a/doc/README.md +++ b/doc/README.md @@ -575,6 +575,8 @@ some of its requirements via coursier, - [jupyter-scala](https://github.com/alexarchambault/jupyter-scala) is launched and allows to add dependencies in its sessions with coursier (initial motivation for writing coursier), +- [Apache Toree](https://github.com/apache/incubator-toree) - formerly known as [spark-kernel](https://github.com/ibm-et/spark-kernel), is now using coursier to +add dependencies on-the-fly ([#4](https://github.com/apache/incubator-toree/pull/4)), - Your project here :-) From 989c52055b2a98d33d553deb03b99adb9bddc409 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Sun, 21 Feb 2016 20:22:48 +0100 Subject: [PATCH 3/4] Make the printed ivy2Local in README look more anonymous --- README.md | 12 +++++++++++- doc/README.md | 37 +++++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 3 deletions(-) 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( From 9548f286936338ce4bb2177dde3d10ce82132e94 Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Sun, 21 Feb 2016 20:22:49 +0100 Subject: [PATCH 4/4] Fix typo in README --- README.md | 2 +- doc/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b133b4c7e..a4a68c3f7 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ and is able to fetch metadata and artifacts from both Maven and Ivy repositories Compared to the default dependency resolution of SBT, it adds: * downloading of artifacts in parallel, -* better offline mode - one can safely work with snapshot dependencies if these are in cache (SBT tends to try to fail if it cannot check for updates), +* better offline mode - one can safely work with snapshot dependencies if these are in cache (SBT tends to try and fail if it cannot check for updates), * non obfuscated cache (cache structure just mimicks the URL it caches), * no global lock (no "Waiting for ~/.ivy2/.sbt.ivy.lock to be available"). diff --git a/doc/README.md b/doc/README.md index 31ba4bb18..379a0b763 100644 --- a/doc/README.md +++ b/doc/README.md @@ -30,7 +30,7 @@ and is able to fetch metadata and artifacts from both Maven and Ivy repositories Compared to the default dependency resolution of SBT, it adds: * downloading of artifacts in parallel, -* better offline mode - one can safely work with snapshot dependencies if these are in cache (SBT tends to try to fail if it cannot check for updates), +* better offline mode - one can safely work with snapshot dependencies if these are in cache (SBT tends to try and fail if it cannot check for updates), * non obfuscated cache (cache structure just mimicks the URL it caches), * no global lock (no "Waiting for ~/.ivy2/.sbt.ivy.lock to be available").