Upgrade to Pro — share decks privately, control downloads, hide ads and more …

All the fancy things you can do with flexible dependency management

All the fancy things you can do with flexible dependency management

New APIs of coursier (high level, Java, sbt)

coursier install and coursier publish commands


Alexandre Archambault

June 13, 2019

More Decks by Alexandre Archambault

Other Decks in Programming


  1. All the fancy things you can do with flexible dependency

    mgmt Alexandre Archambault @alxarchambault (not a typo) github.com/alexarchambault Scala Center
  2. get-coursier.io 2015 (!) – library + CLI – sbt plugin

    came later 2017: 1.0
  3. get-coursier.io 2015 (!) – library + CLI – sbt plugin

    came later 2017: 1.0
  4. Plan – New APIs: high-level, Java, sbt API – "Enterprise"

    features (better authentication, mirrors, …) – install command – publish command – Demo!
  5. APIs

  6. High-level API

  7. High-level API

  8. High-level API

  9. High-level API

  10. High-level API

  11. High-level API

  12. High-level API

  13. High-level API

  14. High-level API

  15. High-level API

  16. High-level API

  17. High-level API

  18. High-level API

  19. High-level API

  20. High-level API

  21. High-level API

  22. High-level API

  23. High-level API

  24. Purity or getting things done? Both! Pass all the inputs

    explicitly if you want to Get results in an IO Relies on all the defaults Get results or an exception, synchronously
  25. Former API

  26. Former API

  27. Java API Minimum surface area Even more conservative in terms

    of binary compatibility Shades coursier, scala-library too Goals – Java users? – Lower chances of conflicts (scalafmt- dynamic, Ammonite?, dotty?)
  28. APIs High-level API – Simpler API, closer to the CLI,

    while still retaining purity Java API – Stability, binary compatibility Also – lm-coursier (implementing sbt/library-management)
  29. sbt API

  30. Early implementations

  31. sbt-coursier sbt coursier sbt-lm sbt-coursier sbt lm-coursier sbt-lm coursier lm-coursier-shaded

    coursier sbt sbt-lm sbt-lm-coursier
  32. Enterprise features

  33. Rules Enforce constraints Fix them automatically, or fail Available –

    Strict – DontBumpRootDependencies – SameVersion Resolution strategy – Try to fix – Warn – Fail
  34. Reworked authentication Read credentials from file Pass on redirect (or

    not) Restrict to https (default) … For now: applied by host
  35. Mirrors Substitute internal repositories to Central, etc. For the coursier

    CLI mostly
  36. install

  37. Motivation Distribute apps just like libraries – No launchers to

    handle / push / distribute / download… – But (slightly) more cumbersome command for end-users
  38. Even more complex for more advanced apps – dotty-repl –

    scalac – mill? – …
  39. Couldn't we just do $ coursier install dotty-repl $ coursier

    launch scalafmt:1.6.0-RC4
  40. install demo

  41. App descriptions – in JSON at specific paths or URLs

    https://github.com/coursier/ apps/blob/extras/apps.json – from "channels" (JAR published on a Maven repository, containing JSON files for multiple apps) Default channel: io.get-coursier:apps, via github.com/coursier/apps
  42. install Installs – JVM apps – scala-native apps (built locally

    from Maven artifacts) – graalvm native image generation Updates – changes in source (JSON) – new artifacts (if latest.* or version interval) Only relies on the coursier cache – no git clone, …
  43. publish

  44. Disclaimer sbt-ci-release (harnessing sbt-git, sbt-sonatype, sbt-pgp, sbt-dynver) mill basically work

  45. Workflow Build tool writes (all) artifacts to a directory Then

    the publish command takes over, and publishes that
  46. Principle Take one or more "sources" – Think sbt projects,

    existing directories with pre-defined structure, … Transform them – Adjust organization, version, etc. (changes POM files, paths) – Add missing metadata (maven-metadata.xml) – Add missing checksums, signatures – Snapshot versioning Write / push them somewhere – In a local directory, to a remote repository, …
  47. install + publish demo