All of these can be figured out by looking at ammonite.io and at libraries pages, but to make things faster for myself I written it down (I don't always want to search through Ammonite history nor pollute my ~/.ammonite/predef.sc
).
For convenience, next to library there is badge with the newest version and next to one liners for Ammonite for specific version is link to releases - it let you update to newest version without goolging or checking project's site.
- Ammonite for specific Scala version
- Generate Ammonite import format from sbt/coursier import format
- Standard library utils
- Set compiler flags
- Load compiler plugins
- Import libraries
(ToC generated using Markdown TOC generate)
Last release of 2.10 (1.0.3)
[ -f /tmp/ammonite-2.10/amm ] || (mkdir /tmp/ammonite-2.10 -p && curl -L https://github.com/lihaoyi/Ammonite/releases/download/1.0.3/2.10-1.0.3 > /tmp/ammonite-2.10/amm && chmod +x /tmp/ammonite-2.10/amm) && /tmp/ammonite-2.10/amm
Last release of 2.11 (1.6.7)
[ -f /tmp/ammonite-2.11/amm ] || (mkdir /tmp/ammonite-2.11 -p && curl -L https://github.com/lihaoyi/Ammonite/releases/download/1.6.7/2.11-1.6.7 > /tmp/ammonite-2.11/amm && chmod +x /tmp/ammonite-2.11/amm) && /tmp/ammonite-2.11/amm
[ -f /tmp/ammonite-2.12/amm ] || (mkdir /tmp/ammonite-2.12 -p && curl -L https://github.com/lihaoyi/Ammonite/releases/download/2.1.4/2.12-2.1.4 > /tmp/ammonite-2.12/amm && chmod +x /tmp/ammonite-2.12/amm) && /tmp/ammonite-2.12/amm
[ -f /tmp/ammonite-2.13/amm ] || (mkdir /tmp/ammonite-2.13 -p && curl -L https://github.com/lihaoyi/Ammonite/releases/download/2.1.4/2.13-2.1.4 > /tmp/ammonite-2.13/amm && chmod +x /tmp/ammonite-2.13/amm) && /tmp/ammonite-2.13/amm
implicit class PrintImport(deps: coursierapi.Dependency) {
def forAmmonite(mock: Any): Unit = println(s"import $$ivy.`${deps.getModule.getOrganization}:${deps.getModule.getName}:${deps.getVersion}`")
def fetch(mock: Any): Unit = interp.load.ivy(deps)
}
Copy-paste sbt dependency into Ammonite, add forAmmonite ()
and run it
@ "org.typelevel" %% "cats-core" % "2.1.1" forAmmonite ()
import $ivy.`org.typelevel:cats-core_2.13:2.1.1`
then copy-paste output of forAmmnite ()
in order to import it or share with others or
@ "org.typelevel" %% "cats-core" % "2.1.1" fetch ()
to fetch dependencies and make them available in REPL.
import scala.util._, scala.concurrent._, scala.concurrent.duration._
Not use together with monix.execution.Scheduler
import scala.concurrent.ExecutionContext.Implicits.global
2.13-only
import scala.util.chaining._
2.13-only, 2.12 needs Macro paradise
interp.configureCompiler(_.settings.YmacroAnnotations.value = true)
interp.configureCompiler(_.settings.XlogImplicits.value = true)
Build-in in 2.13, only needed in 2.12
interp.configureCompiler(_.settings.YpartialUnification.value = true)
import $plugin.$ivy.`org.typelevel:kind-projector_2.13.2:0.11.0`
import $plugin.$ivy.`com.olegpy::better-monadic-for:0.3.1`
2.13 replaced it with Ymacro-annotation compiler flag
import $plugin.$ivy.`org.scalamacros:paradise_2.12.11:2.1.1`
import $plugin.$ivy.`io.tryp:splain_2.13.2:0.5.6`
import $ivy.`org.typelevel::cats-core:2.1.0`, cats._, cats.data._, cats.implicits._
import $ivy.`org.typelevel::cats-effect:2.1.3`, cats.effect._
import `org.typelevel::kittens:2.1.0`, cats.derived.auto._
import $ivy.`io.circe::circe-generic:0.13.0`, io.circe._, io.circe.generic.auto._
import $ivy.`io.circe::circe-parser:0.13.0`, io.circe.parser._
import $ivy.`io.circe::circe-optics:0.13.0`, io.circe.optics.JsonPath._
import $ivy.`com.beachape::enumeratum:1.6.0`, enumeratum._
import $ivy.`com.beachape::enumeratum-circe:1.6.0`, enumeratum._
import $ivy.`co.fs2::fs2-core:2.3.0`, fs2._
import $ivy.`co.fs2::fs2-io:2.3.0`, fs2._
import $ivy.`io.monix::monix:3.2.1`, monix.eval._, monix.execution._
import monix.execution.Scheduler.Implicits.global
import $ivy.`com.github.pureconfig::pureconfig:0.12.3`, pureconfig._
import $ivy.`com.chuusai::shapeless:2.3.3`, shapeless._
import $ivy.`io.scalaland::chimney:0.5.2`, io.scalaland.chimney.dsl._
import $ivy.`io.scalaland::chimney-cats:0.5.2`, io.scalaland.chimney.cats._
interp.configureCompiler(_.settings.YmacroAnnotations.value = true)
import $ivy.`io.scalaland::catnip:1.0.0`, io.scalaland.catnip._, cats._, cats.implicits._, alleycats.std.all._
import $ivy.`io.scalaland::enumz:1.0.0`, io.scalaland.enumz.Enum
URL shortener: https://bit.do/ammonite-snippets