Iām writing an ammonite script to work with Github4s library to access the github api and have a issue, probably with the classpath. The simple version of the script is as follows:
import $ivy.`com.47deg::github4s:0.17.0`, github4s.Github, github4s.Github._, github4s.jvm.Implicits._, scalaj.http.HttpResponse
val listCommits = Github().repos.listCommits("lihaoyi", "ammonite")
listCommits.exec[cats.Id, HttpResponse[String]]() match {
case Left(e) => println(s"Something went wrong: ${e.getMessage}")
case Right(r) => r.result.foreach { commit => println(s"${commit.sha}:
${commit.message.take(35)}") }
}
It's pretty much copied from the github4s tutorial and it fails with:
java.lang.AbstractMethodError
jawn.CharBasedParser.parseString(CharBasedParser.scala:90)
jawn.CharBasedParser.parseString$(CharBasedParser.scala:87)
jawn.StringParser.parseString(StringParser.scala:15)
jawn.Parser.rparse(Parser.scala:428)
jawn.Parser.parse(Parser.scala:337)
jawn.SyncParser.parse(SyncParser.scala:24)
jawn.SupportParser.$anonfun$parseFromString$1(SupportParser.scala:15)
jawn.SupportParser.parseFromString(SupportParser.scala:15)
jawn.SupportParser.parseFromString$(SupportParser.scala:14)
io.circe.jawn.CirceSupportParser$.parseFromString(CirceSupportParser.scala:7)
io.circe.jawn.JawnParser.parse(JawnParser.scala:16)
io.circe.parser.package$.parse(package.scala:8)
io.circe.Parser.decode(Parser.scala:26)
io.circe.Parser.decode$(Parser.scala:25)
io.circe.parser.package$.decode(package.scala:5)
github4s.HttpRequestBuilderExtensionJVM.decodeEntity(HttpRequestBuilderExtensionJVM.scala:89)
github4s.HttpRequestBuilderExtensionJVM.decodeEntity$(HttpRequestBuilderExtensionJVM.scala:88)
github4s.jvm.Implicits$.decodeEntity(Implicits.scala:21)
Exactly the the same code works in a simple SBT project that makes me think Ammonite injects something in the classpath and it breaks github4s.
Is there a way to have a cleaner classpath in ammonite scripts or how else can I go around this issue?