2015-06-16 20:17:07 +02:00
# Coursier
*Pure Scala Artifact Fetching*
A pure Scala substitute for [Aether ](http://www.eclipse.org/aether/ )
2015-06-16 20:38:47 +02:00
[](https://travis-ci.org/alexarchambault/coursier)
2015-07-08 12:47:01 +02:00
[](https://ci.appveyor.com/project/alexarchambault/coursier)
2015-07-05 15:40:58 +02:00
[](https://gitter.im/alexarchambault/coursier?utm_source=badge& utm_medium=badge& utm_campaign=pr-badge& utm_content=badge)
2015-12-19 18:28:48 +01:00
[](https://maven-badges.herokuapp.com/maven-central/com.github.alexarchambault/coursier_2.11)
2015-06-16 20:38:47 +02:00
2015-11-27 01:21:07 +01:00
*coursier* is a dependency resolver / fetcher *à la* Maven / Ivy, entirely
rewritten from scratch in Scala. It aims at being fast and easy to embed
in other contexts. Its very core (`core` module) aims at being
2015-11-28 18:42:38 +01:00
extremely pure, and should be approached thinking algebraically.
2015-06-16 20:38:47 +02:00
2015-12-30 22:54:39 +01:00
The `cache` module handles caching of the metadata and artifacts themselves,
2015-11-27 01:21:07 +01:00
and is less so pure than the `core` module, in the sense that it happily
does IO as a side-effect (although it naturally favors immutability for all
that's kept in memory).
2015-06-16 20:38:47 +02:00
2015-11-27 01:21:07 +01:00
It handles fancy Maven features like
2015-06-16 20:17:07 +02:00
* [POM inheritance ](http://books.sonatype.com/mvnref-book/reference/pom-relationships-sect-project-relationships.html#pom-relationships-sect-project-inheritance ),
* [dependency management ](http://books.sonatype.com/mvnex-book/reference/optimizing-sect-dependencies.html ),
* [import scope ](https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies ),
2015-11-27 01:21:07 +01:00
* [properties ](http://books.sonatype.com/mvnref-book/reference/resource-filtering-sect-properties.html ),
2015-11-27 01:32:52 +01:00
* etc.
2015-11-27 01:21:07 +01:00
It happily resolves dependencies involving modules from the Hadoop ecosystem (Spark, Flink, etc.), that
make a heavy use of these.
It can be used either from the command-line, via its API, or from the browser.
2015-11-28 18:42:38 +01:00
It downloads the metadata or the artifacts in parallel (usually, 6 parallel
downloads).
2015-11-27 01:21:07 +01:00
## Command-line
2015-11-28 18:42:38 +01:00
Download and run its laucher with
2015-11-27 01:21:07 +01:00
```
2015-12-31 01:15:09 +01:00
$ curl -L -o coursier https://git.io/vEpQR & & chmod +x coursier & & ./coursier --help
2015-11-27 01:21:07 +01:00
```
2015-11-28 18:42:38 +01:00
Note that the launcher itself weights only 8 kB and can be easily
embedded as is in other projects.
2015-11-27 01:21:07 +01:00
The first time it is run, it will download the artifacts required to launch
coursier. You'll be fine the next times :-).
2015-11-28 18:42:38 +01:00
The cache of this default launcher defaults to a directory named `.coursier` ,
in the same directory as the launcher. This can be changed by manually adjusting
the `COURSIER_CACHE` variable in the first lines of the launcher.
2015-11-27 01:21:07 +01:00
```
$ ./coursier --help
```
lists the available coursier commands. The most notable ones are `launch` ,
2015-12-31 01:15:09 +01:00
and `fetch` . Type
2015-11-27 01:21:07 +01:00
```
$ ./coursier command --help
```
to get a description of the various options the command `command` (replace with one
of the above command) accepts.
### launch
The `launch` command fetches a set of Maven coordinates it is given, along
with their transitive dependencies, then launches the "main `main` class" from
it if it can find one (typically from the manifest of the first coordinates).
The main class to launch can also be manually specified with the `-M` option.
For example, it can launch:
* [Ammonite ](https://github.com/lihaoyi/Ammonite ) (enhanced Scala REPL),
```
2015-12-31 01:15:09 +01:00
$ ./coursier launch com.lihaoyi:ammonite-repl_2.11.7:0.5.2
2015-11-27 01:21:07 +01:00
```
2015-11-27 01:32:52 +01:00
along with the REPLs of various JVM languages like
* Frege,
2015-11-27 01:21:07 +01:00
```
2015-11-27 01:32:52 +01:00
$ ./coursier launch -r central -r https://oss.sonatype.org/content/groups/public \
org.frege-lang:frege-repl-core:1.3 -M frege.repl.FregeRepl
2015-11-27 01:21:07 +01:00
```
2015-11-27 01:32:52 +01:00
* clojure,
2015-11-27 01:21:07 +01:00
```
$ ./coursier launch org.clojure:clojure:1.7.0 -M clojure.main
```
2015-11-27 01:32:52 +01:00
* jruby,
2015-11-27 01:21:07 +01:00
```
$ wget https://raw.githubusercontent.com/jruby/jruby/master/bin/jirb & & \
./coursier launch org.jruby:jruby:9.0.4.0 -M org.jruby.Main -- -- jirb
```
2015-11-27 01:32:52 +01:00
* jython,
2015-11-27 01:21:07 +01:00
```
$ ./coursier launch org.python:jython-standalone:2.7.0 -M org.python.util.jython
```
2015-11-27 01:32:52 +01:00
* Groovy,
2015-11-27 01:21:07 +01:00
```
2015-11-27 01:32:52 +01:00
$ ./coursier launch org.codehaus.groovy:groovy-groovysh:2.4.5 -M org.codehaus.groovy.tools.shell.Main \
commons-cli:commons-cli:1.3.1
2015-11-27 01:21:07 +01:00
```
2015-11-27 01:32:52 +01:00
2015-11-27 01:21:07 +01:00
etc.
2015-11-27 01:32:52 +01:00
and various programs, like
* Proguard and its utility Retrace,
2015-11-27 01:21:07 +01:00
```
$ ./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
```
### fetch
The `fetch` command simply fetches a set of dependencies, along with their
transitive dependencies, then prints the local paths of all their artefacts.
Example
```
$ ./coursier fetch org.apache.spark:spark-sql_2.11:1.5.2
...
2015-11-27 01:32:52 +01:00
/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
...
2015-11-27 01:21:07 +01:00
```
2015-12-31 01:15:09 +01:00
By adding the `-p` option, these paths can be handed over directly to
`java -cp` , like
2015-11-27 01:21:07 +01:00
```
2015-12-31 01:15:09 +01:00
$ java -cp "$(./coursier fetch -p com.lihaoyi:ammonite-repl_2.11.7:0.5.2)" ammonite.repl.Main
2015-11-27 01:21:07 +01:00
Loading...
2015-12-31 01:15:09 +01:00
Welcome to the Ammonite Repl 0.5.2
(Scala 2.11.7 Java 1.8.0_51)
2015-11-27 01:21:07 +01:00
@
```
## API
More explanations to come :-)
## Scala JS demo
*coursier* is also compiled to Scala JS, and can be tested in the browser via its
[demo ](http://alexarchambault.github.io/coursier/#demo ).
# Contributors
- Your name here :-)
2015-11-27 01:32:52 +01:00
Don't hesitate to pick an issue to contribute, and / or ask for help for how to proceed
on the [Gitter channel ](https://gitter.im/alexarchambault/coursier ).
2015-11-27 01:21:07 +01:00
# Projects using coursier
2015-06-16 20:17:07 +02:00
2015-11-27 01:32:52 +01:00
- [Lars Hupel ](https://github.com/larsrh/ )'s [libisabelle ](https://github.com/larsrh/libisabelle ) fetches
2015-11-27 01:21:07 +01:00
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),
- Your project here :-)
2015-06-16 20:17:07 +02:00
Released under the Apache license, v2.