1.1.0-M13 was just released.
The most notable changes of this milestone happened in the new high level API, that is nearing completion. A notion of "rules" or constraints is also being added to coursier, and should be described in more detail in a later post.
High level API
This API aims at being as simple to use as the CLI of coursier, while retaining the purity of the former low level API - without all its traps.
For example, one can fetch a few dependencies with
import coursier._ val files = Fetch() .addDependencies( dep"org.http4s:http4s-dsl_2.12:0.18.22", dep"org.tpolecat:doobie-core_2.12:0.6.0" ) .run() // files: Seq[java.io.File]
It relies on a "builder pattern", not unlike sttp. Numerous parameters can be adjusted by calling other methods before
run, such as
run() runs resolutions and downloads artifacts synchronously, but can be substituted by
io to run things in the background, via a
Future or the IO monad of your choice.
More details can be found in the documentation.
The CLI and the sbt plugins of coursier already rely on this API. In the future, this should ensure that more advanced features, added in the CLI or the sbt plugin of coursier, are available to API users straightaway. It's also easier to evolve this API while retaining binary compatibility.
Motivated by SCP-20, support for enforcing some "rules" or constraints is being added to coursier. These are a bit similar to those of the Maven enforcer plugin, and allow to emulate the strict conflict manager of Ivy in particular.
While details are still being ironed out, the CLI already accepts rules.
For example, one can require all the jackson modules to have the same version with
$ coursier resolve org.apache.spark:spark-sql_2.12:2.4.0 \ --rules 'SameVersion(com.fasterxml.jackson.*:jackson-*)' … com.fasterxml.jackson.core:jackson-annotations:2.7.9:default com.fasterxml.jackson.core:jackson-core:2.7.9:default com.fasterxml.jackson.core:jackson-databind:2.7.9:default com.fasterxml.jackson.module:jackson-module-paranamer:2.7.9:default com.fasterxml.jackson.module:jackson-module-scala_2.12:2.7.9:default …
By default, if a rule doesn't pass, it can try to address the underlying issue. One can instead require resolution to fail, with
$ coursier resolve org.apache.spark:spark-sql_2.12:2.4.0 \ --rules 'fail:SameVersion(com.fasterxml.jackson.*:jackson-*)' Resolution error: Unsatisfiable rule …
An upcoming post should describe rules and future plans in more detail.