Merge pull request #257 from alexarchambault/topic/updates

Various things for 1.0.0-M12-1
This commit is contained in:
Alexandre Archambault 2016-05-23 09:54:22 +02:00
commit 3ffba8b974
10 changed files with 212 additions and 65 deletions

View File

@ -88,20 +88,16 @@ $ brew install --HEAD paulp/extras/coursier
Run an application distributed via artifacts with
```
$ ./coursier launch com.lihaoyi:ammonite-repl_2.11.7:0.5.2
$ ./coursier launch com.lihaoyi:ammonite-repl_2.11.8:0.5.7
```
Download and list the classpath of one or several dependencies with
```
$ ./coursier fetch org.apache.spark:spark-sql_2.11:1.5.2 com.twitter:algebird-spark_2.11:0.11.0
Dependencies:
org.apache.spark:spark-sql_2.11:1.5.2
com.twitter:algebird-spark_2.11:0.11.0
Fetching artifacts
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/com/sun/jersey/jersey-client/1.9/jersey-client-1.9.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/net/jpountz/lz4/lz4/1.3.0/lz4-1.3.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/com/clearspring/analytics/stream/2.7.0/stream-2.7.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/com/typesafe/config/1.2.1/config-1.2.1.jar
$ ./coursier fetch org.apache.spark:spark-sql_2.11:1.6.1 com.twitter:algebird-spark_2.11:0.12.0
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/com/twitter/algebird-spark_2.11/0.12.0/algebird-spark_2.11-0.12.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/com/twitter/algebird-core_2.11/0.12.0/algebird-core_2.11-0.12.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/apache/hadoop/hadoop-annotations/2.2.0/hadoop-annotations-2.2.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/tukaani/xz/1.0/xz-1.0.jar
...
```
@ -131,10 +127,10 @@ To resolve dependencies, first create a `Resolution` case class with your depend
val start = Resolution(
Set(
Dependency(
Module("org.scalaz", "scalaz-core_2.11"), "7.2.0"
Module("org.scalaz", "scalaz-core_2.11"), "7.2.3"
),
Dependency(
Module("org.spire-math", "cats-core_2.11"), "0.3.0"
Module("org.typelevel", "cats-core_2.11"), "0.6.0"
)
)
)
@ -175,8 +171,8 @@ val localArtifacts: Seq[FileError \/ File] = Task.gatherUnordered(
The default global cache used by coursier is `~/.coursier/cache/v1`. E.g. the artifact at
`https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.11.7/scala-library-2.11.7.jar`
will land in `~/.coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.11.7/scala-library-2.11.7.jar`.
`https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.11.8/scala-library-2.11.8.jar`
will land in `~/.coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.11.8/scala-library-2.11.8.jar`.
From the SBT plugin, the default repositories are the ones provided by SBT (typically Central or JFrog, and `~/.ivy2/local`).
From the CLI tools, these are Central (`https://repo1.maven.org/maven2`) and `~/.ivy2/local`.
@ -219,7 +215,7 @@ addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M12")
to `~/.sbt/0.13/plugins/build.sbt`
To enable it on a per-project basis, add it only to the `project/plugins.sbt` of a SBT project.
The SBT plugin has been tested only with SBT 0.13.8 / 0.13.9.
The SBT plugin has been tested only with SBT 0.13.8 / 0.13.9 / 0.13.11. It doesn't currently work with the SBT 1.0 milestones.
Once enabled, the `update`, `updateClassifiers`, and `updateSbtClassifiers` commands are taken care of by coursier. These
provide more output about what's going on than their default implementations do.
@ -227,6 +223,17 @@ provide more output about what's going on than their default implementations do.
TEMPORARY As of the `1.0.0-M12` version, the SBT plugin doesn't re-use the `credentials` setting from SBT yet.
To enable credentials for a repository, add its credentials to `coursierCredentials`, like
```scala
resolvers += "corp-releases" at "http://nexus.corp.com/content/repositories/releases"
coursierCredentials += "corp-releases" -> coursier.Credentials("user", "pass")
// alternatively, read credentials from a file
coursierCredentials += "corp-releases" -> coursier.Credentials(file("path/to/credentials"))
```
Future versions of the plugin should support the `credentials` setting out-of-the-box.
### Command-line
@ -266,6 +273,11 @@ unless the `--no-default` option is specified.
Repositories starting with `ivy:` are assumed to be Ivy repositories, specified with an Ivy pattern, like `ivy:https://repo.typesafe.com/typesafe/ivy-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]`.
Else, a Maven repository is assumed.
To set credentials for a repository, pass a user and password in its URL, like
```
-r https://user:pass@nexus.corp.com/content/repositories/releases
```
#### launch
The `launch` command fetches a set of Maven coordinates it is given, along
@ -277,7 +289,7 @@ For example, it can launch:
* [Ammonite](https://github.com/lihaoyi/Ammonite) (enhanced Scala REPL),
```
$ ./coursier launch com.lihaoyi:ammonite-repl_2.11.7:0.5.2
$ ./coursier launch com.lihaoyi:ammonite-repl_2.11.8:0.5.7
```
along with the REPLs of various JVM languages like
@ -320,6 +332,14 @@ $ ./coursier launch net.sf.proguard:proguard-base:5.2.1 -M proguard.ProGuard
$ ./coursier launch net.sf.proguard:proguard-retrace:5.2.1 -M proguard.retrace.ReTrace
```
* Wiremock,
```
./coursier launch com.github.tomakehurst:wiremock:1.57 -- \
--proxy-all="http://search.twitter.com" --record-mappings --verbose
```
If you wish to pass additional argument to the artifact being launched, separate them from the coursier's parameters list with the "--", just like in the Wiremock example above.
#### fetch
The `fetch` command simply fetches a set of dependencies, along with their
@ -327,21 +347,21 @@ transitive dependencies, then prints the local paths of all their artifacts.
Example
```
$ ./coursier fetch org.apache.spark:spark-sql_2.11:1.5.2
...
/path/to/.coursier/cache/0.1.0-SNAPSHOT-2f5e731/files/central/io/dropwizard/metrics/metrics-jvm/3.1.2/metrics-jvm-3.1.2.jar
/path/to/.coursier/cache/0.1.0-SNAPSHOT-2f5e731/files/central/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.jar
/path/to/.coursier/cache/0.1.0-SNAPSHOT-2f5e731/files/central/javax/inject/javax.inject/1/javax.inject-1.jar
$ ./coursier fetch org.apache.spark:spark-sql_2.11:1.6.1
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/apache/hadoop/hadoop-annotations/2.2.0/hadoop-annotations-2.2.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/tukaani/xz/1.0/xz-1.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/tachyonproject/tachyon-underfs-s3/0.8.2/tachyon-underfs-s3-0.8.2.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/glassfish/grizzly/grizzly-http/2.1.2/grizzly-http-2.1.2.jar
...
```
By adding the `-p` option, these paths can be handed over directly to
`java -cp`, like
```
$ java -cp "$(./coursier fetch -p com.lihaoyi:ammonite-repl_2.11.7:0.5.2)" ammonite.repl.Main
$ java -cp "$(./coursier fetch -p com.lihaoyi:ammonite-repl_2.11.8:0.5.7)" ammonite.repl.Main
Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_51)
Welcome to the Ammonite Repl 0.5.7
(Scala 2.11.8 Java 1.8.0_60)
@
```
@ -400,10 +420,10 @@ Resolving dependencies involves create an initial resolution state, with all the
val start = Resolution(
Set(
Dependency(
Module("org.spire-math", "cats-core_2.11"), "0.3.0"
Module("org.typelevel", "cats-core_2.11"), "0.6.0"
),
Dependency(
Module("org.scalaz", "scalaz-core_2.11"), "7.2.0"
Module("org.scalaz", "scalaz-core_2.11"), "7.2.3"
)
)
)
@ -434,7 +454,7 @@ we added above. As we can see, it is an `IvyRepository`, picking things under `~
is related to the [Ivy](http://ant.apache.org/ivy/) build tool. This kind of repository involves a so-called [pattern](http://ant.apache.org/ivy/history/2.4.0/concept.html#patterns), with
various properties. These are not of very common use in Scala, although SBT uses them a bit.
The second repository in a `MavenRepository`. These are simpler than the Ivy repositories. They're the ones
The second repository is a `MavenRepository`. These are simpler than the Ivy repositories. They're the ones
we're the most used to in Scala. Common ones like [Central](https://repo1.maven.org/maven2) like here, or the repositories
from [Sonatype](https://oss.sonatype.org/content/repositories/), are Maven repositories. These originate
from the [Maven](https://maven.apache.org/) build tool. Unlike the Ivy repositories which involve customisable patterns to point
@ -445,6 +465,18 @@ like for any particular version of the standard library, under paths like
Both `IvyRepository` and `MavenRepository` are case classes, so that it's straightforward to specify one's own
repositories.
To set credentials for a `MavenRepository` or `IvyRepository`, set their `authentication` field, like
```scala
scala> import coursier.core.Authentication
import coursier.core.Authentication
scala> MavenRepository(
| "https://nexus.corp.com/content/repositories/releases",
| authentication = Some(Authentication("user", "pass"))
| )
res6: coursier.maven.MavenRepository = MavenRepository(https://nexus.corp.com/content/repositories/releases,None,false,Some(Authentication(user, *******)))
```
Now that we have repositories, we're going to mix these with things from the `coursier-cache` module,
for resolution to happen via the cache. We'll create a function
of type `Seq[(Module, String)] => F[Seq[((Module, String), Seq[String] \/ (Artifact.Source, Project))]]`.
@ -610,7 +642,7 @@ spark-core tries to exclude `org.jboss.netty:netty` to land in its classpath via
it does not via the former path. So it depends on it according to the
[Maven documentation](https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html#Dependency_Exclusions).
This likely unintended, as it leads to exceptions like
This is likely unintended, as it leads to exceptions like
```
java.lang.VerifyError: (class: org/jboss/netty/channel/socket/nio/NioWorkerPool, method: createWorker signature: (Ljava/util/concurrent/Executor;)Lorg/jboss/netty/channel/socket/nio/AbstractNioWorker;) Wrong return type in function
```
@ -618,9 +650,10 @@ Excluding `org.jboss.netty:netty` from the spark dependencies fixes it.
#### The coursier SBT plugin flow my CI output with messages. What can I do?
Set the `COURSIER_NO_TERM` environment variable to `1`. This disables the
Set the `COURSIER_PROGRESS` environment variable to `0`. This disables the
progress bar message, and prints simple `Downloading URL` / `Downloaded URL`
instead.
instead. Alternatively, if SBT is launched via the [sbt-extras](https://github.com/paulp/sbt-extras)
launcher, pass it the `-batch` option, or have its stdin be `/dev/null` with `sbt ... < /dev/null`.
#### On first launch, the coursier launcher downloads a 1.5+ MB JAR. Is it possible to have a standalone launcher, that would not need to download things on first launch?
@ -647,6 +680,10 @@ $ COURSIER_CACHE=$(pwd)/.coursier-cache sbt
## Development tips
In general, as coursier has a few modules that target either only scala 2.10 or 2.11, it is recommended
to systematically force the scala version, with the `++2.11.8` or `++2.10.6` commands. The `cli` module
in particular is only built in 2.11, and the `plugin` one only in 2.10.
#### Working on the plugin module in an IDE
Set `scalaVersion` to `2.10.6` in `build.sbt`. Then re-open / reload the coursier project.

View File

@ -65,9 +65,12 @@ object TermDisplay {
def nonInteractive = System.console() == null
def insideEmacs = sys.env.contains("INSIDE_EMACS")
def ci = sys.env.contains("CI")
val env = env0.getOrElse(compatibilityEnv)
env || nonInteractive
env || nonInteractive || insideEmacs || ci
}

View File

@ -88,20 +88,16 @@ $ brew install --HEAD paulp/extras/coursier
Run an application distributed via artifacts with
```
$ ./coursier launch com.lihaoyi:ammonite-repl_2.11.7:0.5.2
$ ./coursier launch com.lihaoyi:ammonite-repl_2.11.8:0.5.7
```
Download and list the classpath of one or several dependencies with
```
$ ./coursier fetch org.apache.spark:spark-sql_2.11:1.5.2 com.twitter:algebird-spark_2.11:0.11.0
Dependencies:
org.apache.spark:spark-sql_2.11:1.5.2
com.twitter:algebird-spark_2.11:0.11.0
Fetching artifacts
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/com/sun/jersey/jersey-client/1.9/jersey-client-1.9.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/net/jpountz/lz4/lz4/1.3.0/lz4-1.3.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/com/clearspring/analytics/stream/2.7.0/stream-2.7.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/com/typesafe/config/1.2.1/config-1.2.1.jar
$ ./coursier fetch org.apache.spark:spark-sql_2.11:1.6.1 com.twitter:algebird-spark_2.11:0.12.0
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/com/twitter/algebird-spark_2.11/0.12.0/algebird-spark_2.11-0.12.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/com/twitter/algebird-core_2.11/0.12.0/algebird-core_2.11-0.12.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/apache/hadoop/hadoop-annotations/2.2.0/hadoop-annotations-2.2.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/tukaani/xz/1.0/xz-1.0.jar
...
```
@ -153,10 +149,10 @@ To resolve dependencies, first create a `Resolution` case class with your depend
val start = Resolution(
Set(
Dependency(
Module("org.scalaz", "scalaz-core_2.11"), "7.2.0"
Module("org.scalaz", "scalaz-core_2.11"), "7.2.3"
),
Dependency(
Module("org.spire-math", "cats-core_2.11"), "0.3.0"
Module("org.typelevel", "cats-core_2.11"), "0.6.0"
)
)
)
@ -197,8 +193,8 @@ val localArtifacts: Seq[FileError \/ File] = Task.gatherUnordered(
The default global cache used by coursier is `~/.coursier/cache/v1`. E.g. the artifact at
`https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.11.7/scala-library-2.11.7.jar`
will land in `~/.coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.11.7/scala-library-2.11.7.jar`.
`https://repo1.maven.org/maven2/org/scala-lang/scala-library/2.11.8/scala-library-2.11.8.jar`
will land in `~/.coursier/cache/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.11.8/scala-library-2.11.8.jar`.
From the SBT plugin, the default repositories are the ones provided by SBT (typically Central or JFrog, and `~/.ivy2/local`).
From the CLI tools, these are Central (`https://repo1.maven.org/maven2`) and `~/.ivy2/local`.
@ -241,7 +237,7 @@ addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.0-M12")
to `~/.sbt/0.13/plugins/build.sbt`
To enable it on a per-project basis, add it only to the `project/plugins.sbt` of a SBT project.
The SBT plugin has been tested only with SBT 0.13.8 / 0.13.9.
The SBT plugin has been tested only with SBT 0.13.8 / 0.13.9 / 0.13.11. It doesn't currently work with the SBT 1.0 milestones.
Once enabled, the `update`, `updateClassifiers`, and `updateSbtClassifiers` commands are taken care of by coursier. These
provide more output about what's going on than their default implementations do.
@ -250,6 +246,17 @@ provide more output about what's going on than their default implementations do.
// TODO Change cache policy, sandboxing, parallel downloads, limitations
```
TEMPORARY As of the `1.0.0-M12` version, the SBT plugin doesn't re-use the `credentials` setting from SBT yet.
To enable credentials for a repository, add its credentials to `coursierCredentials`, like
```scala
resolvers += "corp-releases" at "http://nexus.corp.com/content/repositories/releases"
coursierCredentials += "corp-releases" -> coursier.Credentials("user", "pass")
// alternatively, read credentials from a file
coursierCredentials += "corp-releases" -> coursier.Credentials(file("path/to/credentials"))
```
Future versions of the plugin should support the `credentials` setting out-of-the-box.
### Command-line
@ -289,6 +296,11 @@ unless the `--no-default` option is specified.
Repositories starting with `ivy:` are assumed to be Ivy repositories, specified with an Ivy pattern, like `ivy:https://repo.typesafe.com/typesafe/ivy-releases/[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]`.
Else, a Maven repository is assumed.
To set credentials for a repository, pass a user and password in its URL, like
```
-r https://user:pass@nexus.corp.com/content/repositories/releases
```
#### launch
The `launch` command fetches a set of Maven coordinates it is given, along
@ -300,7 +312,7 @@ For example, it can launch:
* [Ammonite](https://github.com/lihaoyi/Ammonite) (enhanced Scala REPL),
```
$ ./coursier launch com.lihaoyi:ammonite-repl_2.11.7:0.5.2
$ ./coursier launch com.lihaoyi:ammonite-repl_2.11.8:0.5.7
```
along with the REPLs of various JVM languages like
@ -343,6 +355,14 @@ $ ./coursier launch net.sf.proguard:proguard-base:5.2.1 -M proguard.ProGuard
$ ./coursier launch net.sf.proguard:proguard-retrace:5.2.1 -M proguard.retrace.ReTrace
```
* Wiremock,
```
./coursier launch com.github.tomakehurst:wiremock:1.57 -- \
--proxy-all="http://search.twitter.com" --record-mappings --verbose
```
If you wish to pass additional argument to the artifact being launched, separate them from the coursier's parameters list with the "--", just like in the Wiremock example above.
#### fetch
The `fetch` command simply fetches a set of dependencies, along with their
@ -350,21 +370,21 @@ transitive dependencies, then prints the local paths of all their artifacts.
Example
```
$ ./coursier fetch org.apache.spark:spark-sql_2.11:1.5.2
...
/path/to/.coursier/cache/0.1.0-SNAPSHOT-2f5e731/files/central/io/dropwizard/metrics/metrics-jvm/3.1.2/metrics-jvm-3.1.2.jar
/path/to/.coursier/cache/0.1.0-SNAPSHOT-2f5e731/files/central/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.jar
/path/to/.coursier/cache/0.1.0-SNAPSHOT-2f5e731/files/central/javax/inject/javax.inject/1/javax.inject-1.jar
$ ./coursier fetch org.apache.spark:spark-sql_2.11:1.6.1
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/apache/hadoop/hadoop-annotations/2.2.0/hadoop-annotations-2.2.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/tukaani/xz/1.0/xz-1.0.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/tachyonproject/tachyon-underfs-s3/0.8.2/tachyon-underfs-s3-0.8.2.jar
/path/to/.coursier/cache/v1/https/repo1.maven.org/maven2/org/glassfish/grizzly/grizzly-http/2.1.2/grizzly-http-2.1.2.jar
...
```
By adding the `-p` option, these paths can be handed over directly to
`java -cp`, like
```
$ java -cp "$(./coursier fetch -p com.lihaoyi:ammonite-repl_2.11.7:0.5.2)" ammonite.repl.Main
$ java -cp "$(./coursier fetch -p com.lihaoyi:ammonite-repl_2.11.8:0.5.7)" ammonite.repl.Main
Loading...
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_51)
Welcome to the Ammonite Repl 0.5.7
(Scala 2.11.8 Java 1.8.0_60)
@
```
@ -425,10 +445,10 @@ Resolving dependencies involves create an initial resolution state, with all the
val start = Resolution(
Set(
Dependency(
Module("org.spire-math", "cats-core_2.11"), "0.3.0"
Module("org.typelevel", "cats-core_2.11"), "0.6.0"
),
Dependency(
Module("org.scalaz", "scalaz-core_2.11"), "7.2.0"
Module("org.scalaz", "scalaz-core_2.11"), "7.2.3"
)
)
)
@ -458,7 +478,7 @@ we added above. As we can see, it is an `IvyRepository`, picking things under `~
is related to the [Ivy](http://ant.apache.org/ivy/) build tool. This kind of repository involves a so-called [pattern](http://ant.apache.org/ivy/history/2.4.0/concept.html#patterns), with
various properties. These are not of very common use in Scala, although SBT uses them a bit.
The second repository in a `MavenRepository`. These are simpler than the Ivy repositories. They're the ones
The second repository is a `MavenRepository`. These are simpler than the Ivy repositories. They're the ones
we're the most used to in Scala. Common ones like [Central](https://repo1.maven.org/maven2) like here, or the repositories
from [Sonatype](https://oss.sonatype.org/content/repositories/), are Maven repositories. These originate
from the [Maven](https://maven.apache.org/) build tool. Unlike the Ivy repositories which involve customisable patterns to point
@ -469,6 +489,16 @@ like for any particular version of the standard library, under paths like
Both `IvyRepository` and `MavenRepository` are case classes, so that it's straightforward to specify one's own
repositories.
To set credentials for a `MavenRepository` or `IvyRepository`, set their `authentication` field, like
```tut
import coursier.core.Authentication
MavenRepository(
"https://nexus.corp.com/content/repositories/releases",
authentication = Some(Authentication("user", "pass"))
)
```
Now that we have repositories, we're going to mix these with things from the `coursier-cache` module,
for resolution to happen via the cache. We'll create a function
of type `Seq[(Module, String)] => F[Seq[((Module, String), Seq[String] \/ (Artifact.Source, Project))]]`.
@ -634,7 +664,7 @@ spark-core tries to exclude `org.jboss.netty:netty` to land in its classpath via
it does not via the former path. So it depends on it according to the
[Maven documentation](https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html#Dependency_Exclusions).
This likely unintended, as it leads to exceptions like
This is likely unintended, as it leads to exceptions like
```
java.lang.VerifyError: (class: org/jboss/netty/channel/socket/nio/NioWorkerPool, method: createWorker signature: (Ljava/util/concurrent/Executor;)Lorg/jboss/netty/channel/socket/nio/AbstractNioWorker;) Wrong return type in function
```
@ -642,9 +672,10 @@ Excluding `org.jboss.netty:netty` from the spark dependencies fixes it.
#### The coursier SBT plugin flow my CI output with messages. What can I do?
Set the `COURSIER_NO_TERM` environment variable to `1`. This disables the
Set the `COURSIER_PROGRESS` environment variable to `0`. This disables the
progress bar message, and prints simple `Downloading URL` / `Downloaded URL`
instead.
instead. Alternatively, if SBT is launched via the [sbt-extras](https://github.com/paulp/sbt-extras)
launcher, pass it the `-batch` option, or have its stdin be `/dev/null` with `sbt ... < /dev/null`.
#### On first launch, the coursier launcher downloads a 1.5+ MB JAR. Is it possible to have a standalone launcher, that would not need to download things on first launch?
@ -671,6 +702,10 @@ $ COURSIER_CACHE=$(pwd)/.coursier-cache sbt
## Development tips
In general, as coursier has a few modules that target either only scala 2.10 or 2.11, it is recommended
to systematically force the scala version, with the `++2.11.8` or `++2.10.6` commands. The `cli` module
in particular is only built in 2.11, and the `plugin` one only in 2.10.
#### Working on the plugin module in an IDE
Set `scalaVersion` to `2.10.6` in `build.sbt`. Then re-open / reload the coursier project.

View File

@ -19,6 +19,7 @@ object CoursierPlugin extends AutoPlugin {
val coursierSourceRepositories = Keys.coursierSourceRepositories
val coursierResolvers = Keys.coursierResolvers
val coursierSbtResolvers = Keys.coursierSbtResolvers
val coursierUseSbtCredentials = Keys.coursierUseSbtCredentials
val coursierCredentials = Keys.coursierCredentials
val coursierFallbackDependencies = Keys.coursierFallbackDependencies
val coursierCache = Keys.coursierCache
@ -62,6 +63,7 @@ object CoursierPlugin extends AutoPlugin {
coursierSourceRepositories := Nil,
coursierResolvers <<= Tasks.coursierResolversTask,
coursierSbtResolvers <<= externalResolvers in updateSbtClassifiers,
coursierUseSbtCredentials := true,
coursierCredentials := Map.empty,
coursierFallbackDependencies <<= Tasks.coursierFallbackDependenciesTask,
coursierCache := Cache.default,

View File

@ -18,6 +18,7 @@ object Keys {
val coursierSourceRepositories = SettingKey[Seq[File]]("coursier-source-repositories")
val coursierResolvers = TaskKey[Seq[Resolver]]("coursier-resolvers")
val coursierSbtResolvers = TaskKey[Seq[Resolver]]("coursier-sbt-resolvers")
val coursierUseSbtCredentials = SettingKey[Boolean]("coursier-use-sbt-credentials")
val coursierCredentials = TaskKey[Map[String, Credentials]]("coursier-credentials")
val coursierCache = SettingKey[File]("coursier-cache")

View File

@ -5,7 +5,7 @@ import java.net.URL
import java.nio.file.Files
import java.util.concurrent.Executors
import coursier.core.Publication
import coursier.core.{ Authentication, Publication }
import coursier.ivy.IvyRepository
import coursier.Keys._
import coursier.Structure._
@ -19,6 +19,7 @@ import sbt.Keys._
import scala.collection.mutable
import scala.collection.JavaConverters._
import scala.util.Try
import scalaz.{ \/-, -\/ }
import scalaz.concurrent.{ Task, Strategy }
@ -371,7 +372,18 @@ object Tasks {
"ivy.home" -> (new File(sys.props("user.home")).toURI.getPath + ".ivy2")
) ++ sys.props
val credentials = coursierCredentials.value
val useSbtCredentials = coursierUseSbtCredentials.value
val authenticationByHost =
if (useSbtCredentials) {
val cred = sbt.Keys.credentials.value.map(sbt.Credentials.toDirect)
cred.map { c =>
c.host -> Authentication(c.userName, c.passwd)
}.toMap
} else
Map.empty[String, Authentication]
val authenticationByRepositoryId = coursierCredentials.value.mapValues(_.authentication)
val sourceRepositories0 = sourceRepositories.map {
base =>
@ -392,6 +404,36 @@ object Tasks {
)
}
def withAuthenticationByHost(repo: Repository, credentials: Map[String, Authentication]): Repository = {
def httpHost(s: String) =
if (s.startsWith("http://") || s.startsWith("https://"))
Try(Cache.url(s).getHost).toOption
else
None
repo match {
case m: MavenRepository =>
if (m.authentication.isEmpty)
httpHost(m.root).flatMap(credentials.get).fold(m) { auth =>
m.copy(authentication = Some(auth))
}
else
m
case i: IvyRepository =>
if (i.authentication.isEmpty) {
val base = i.pattern.takeWhile(c => c != '[' && c != '(' && c != '$')
httpHost(base).flatMap(credentials.get).fold(i) { auth =>
i.copy(authentication = Some(auth))
}
} else
i
case _ =>
repo
}
}
val repositories =
Seq(globalPluginsRepo, interProjectRepo) ++
sourceRepositories0 ++
@ -400,9 +442,9 @@ object Tasks {
resolver,
ivyProperties,
log,
credentials.get(resolver.name).map(_.authentication)
authenticationByRepositoryId.get(resolver.name)
)
} ++
}.map(withAuthenticationByHost(_, authenticationByHost)) ++
fallbackDependenciesRepositories
def resolution = {

View File

@ -0,0 +1,14 @@
scalaVersion := "2.11.8"
resolvers += "authenticated" at "http://localhost:8080"
credentials += Credentials("", "localhost", "user", "pass")
coursierCachePolicies := {
if (sys.props("os.name").startsWith("Windows"))
coursierCachePolicies.value
else
Seq(coursier.CachePolicy.ForceDownload)
}
libraryDependencies += "com.abc" % "test" % "0.1"

View File

@ -0,0 +1,11 @@
{
val pluginVersion = sys.props.getOrElse(
"plugin.version",
throw new RuntimeException(
"""|The system property 'plugin.version' is not defined.
|Specify this property using the scriptedLaunchOpts -D.""".stripMargin
)
)
addSbtPlugin("io.get-coursier" % "sbt-coursier" % pluginVersion)
}

View File

@ -0,0 +1 @@
object Main extends App

View File

@ -0,0 +1 @@
> coursierResolution