Set Gerrit to v3.2.0-rc1

Update Gerrit API to v3.2.0-rc1 and align the associated
libraries with the ones included in Gerrit.

Also adapt the changes to the project cache interface
and the conversion of Java8's Optional to Scala's Option.

Change-Id: I00eb9455ad4bb305a3d014e524d0ece5bea8a717
diff --git a/build.sbt b/build.sbt
index 24ddfd2..837e6c0 100644
--- a/build.sbt
+++ b/build.sbt
@@ -1,6 +1,6 @@
 enablePlugins(GitVersioning)
 
-val gerritApiVersion = "3.1.0-rc1"
+val gerritApiVersion = "3.2.0-rc1"
 
 val pluginName = "analytics"
 
@@ -20,15 +20,16 @@
       "io.fabric8" % "gitective-core" % "0.9.54"
         exclude ("org.eclipse.jgit", "org.eclipse.jgit"),
 
-      "com.google.inject" % "guice" % "4.2.0" % Provided,
+      "com.google.inject" % "guice" % "4.2.3" % Provided,
       "com.google.gerrit" % "gerrit-plugin-api" % gerritApiVersion % Provided withSources(),
       "com.google.code.gson" % "gson" % "2.8.5" % Provided,
       "joda-time" % "joda-time" % "2.9.9",
+      "org.scala-lang.modules" %% "scala-java8-compat" % "0.9.1",
 
       "com.google.gerrit" % "gerrit-acceptance-framework" % gerritApiVersion % Test,
-      "org.bouncycastle" % "bcpg-jdk15on" % "1.60" % Test,
+      "org.bouncycastle" % "bcpg-jdk15on" % "1.61" % Test,
       "org.scalatest" %% "scalatest" % "3.0.1" % Test,
-      "net.codingwell" %% "scala-guice" % "4.1.0" % Test),
+      "net.codingwell" %% "scala-guice" % "4.2.6" % Test),
 
     assemblyJarName in assembly := s"$pluginName.jar",
 
diff --git a/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/CommitsStatisticsLoader.scala b/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/CommitsStatisticsLoader.scala
index 4e8a43e..6adb617 100644
--- a/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/CommitsStatisticsLoader.scala
+++ b/src/main/scala/com/googlesource/gerrit/plugins/analytics/common/CommitsStatisticsLoader.scala
@@ -26,6 +26,7 @@
 import org.eclipse.jgit.revwalk.RevWalk
 import org.eclipse.jgit.treewalk.{CanonicalTreeParser, EmptyTreeIterator}
 import org.eclipse.jgit.util.io.DisabledOutputStream
+import scala.compat.java8.OptionConverters._
 
 import scala.collection.JavaConverters._
 import scala.util.matching.Regex
@@ -44,7 +45,7 @@
     val objectId = cacheKey.commitId
     val nameKey = Project.nameKey(cacheKey.projectName)
     val commentInfoList: Seq[CommentLinkInfo] =
-      if(config.isExtractIssues) projectCache.get(nameKey).getCommentLinks.asScala else Seq.empty
+      if(config.isExtractIssues) projectCache.get(nameKey).asScala.toList.flatMap(_.getCommentLinks.asScala) else Seq.empty
     val replacers = commentInfoList.map(info =>
       Replacer(
         info.`match`.r,