From 51dd3264f5a01265674ca9879e2b9b5e28cdc945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Mon, 22 Nov 2021 12:58:14 +0100 Subject: [PATCH] Fix bug when indexing Scala package repo Previously, we tried to infer the Scala version from the name of the jar of the dependency that we were indexing. Now, we infer from the first jar on the classpath that matches the `2_VERSION` pattern. The old logic didn't work for the sbt package repo, which doesn't include the `_2.12` suffix. --- .../lsif_java/buildtools/LsifBuildTool.scala | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lsif-java/src/main/scala/com/sourcegraph/lsif_java/buildtools/LsifBuildTool.scala b/lsif-java/src/main/scala/com/sourcegraph/lsif_java/buildtools/LsifBuildTool.scala index 91d79596..2be52fb1 100644 --- a/lsif-java/src/main/scala/com/sourcegraph/lsif_java/buildtools/LsifBuildTool.scala +++ b/lsif-java/src/main/scala/com/sourcegraph/lsif_java/buildtools/LsifBuildTool.scala @@ -165,11 +165,11 @@ class LsifBuildTool(index: IndexCommand) extends BuildTool("LSIF", index) { return CommandResult(0, Nil) } - val compileAttemtps = ListBuffer.empty[Try[Unit]] - compileAttemtps += compileJavaFiles(tmp, deps, config, javaFiles) - compileAttemtps += compileScalaFiles(deps, scalaFiles) - compileAttemtps += compileKotlinFiles(deps, config, kotlinFiles) - val errors = compileAttemtps.collect { case Failure(exception) => + val compileAttempts = ListBuffer.empty[Try[Unit]] + compileAttempts += compileJavaFiles(tmp, deps, config, javaFiles) + compileAttempts += compileScalaFiles(deps, scalaFiles) + compileAttempts += compileKotlinFiles(deps, config, kotlinFiles) + val errors = compileAttempts.collect { case Failure(exception) => exception } @@ -179,6 +179,9 @@ class LsifBuildTool(index: IndexCommand) extends BuildTool("LSIF", index) { val isSemanticdbGenerated = Files .isDirectory(targetroot.resolve("META-INF")) if (errors.nonEmpty && !isSemanticdbGenerated) { + errors.foreach { error => + index.app.reporter.log(Diagnostic.exception(error)) + } CommandResult(1, Nil) } else { if (errors.nonEmpty && isSemanticdbGenerated) { @@ -376,8 +379,9 @@ class LsifBuildTool(index: IndexCommand) extends BuildTool("LSIF", index) { )(fn: PresentationCompiler => T): T = { val scalaVersion = deps .classpath - .headOption + .iterator .flatMap(jar => ScalaVersion.inferFromJar(jar)) + .nextOption() .getOrElse { throw new IllegalArgumentException( s"failed to infer the Scala version from the dependencies: " +