Skip to content

Commit 51dd326

Browse files
committed
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.
1 parent 9a74d1b commit 51dd326

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lsif-java/src/main/scala/com/sourcegraph/lsif_java/buildtools/LsifBuildTool.scala

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ class LsifBuildTool(index: IndexCommand) extends BuildTool("LSIF", index) {
165165
return CommandResult(0, Nil)
166166
}
167167

168-
val compileAttemtps = ListBuffer.empty[Try[Unit]]
169-
compileAttemtps += compileJavaFiles(tmp, deps, config, javaFiles)
170-
compileAttemtps += compileScalaFiles(deps, scalaFiles)
171-
compileAttemtps += compileKotlinFiles(deps, config, kotlinFiles)
172-
val errors = compileAttemtps.collect { case Failure(exception) =>
168+
val compileAttempts = ListBuffer.empty[Try[Unit]]
169+
compileAttempts += compileJavaFiles(tmp, deps, config, javaFiles)
170+
compileAttempts += compileScalaFiles(deps, scalaFiles)
171+
compileAttempts += compileKotlinFiles(deps, config, kotlinFiles)
172+
val errors = compileAttempts.collect { case Failure(exception) =>
173173
exception
174174
}
175175

@@ -179,6 +179,9 @@ class LsifBuildTool(index: IndexCommand) extends BuildTool("LSIF", index) {
179179
val isSemanticdbGenerated = Files
180180
.isDirectory(targetroot.resolve("META-INF"))
181181
if (errors.nonEmpty && !isSemanticdbGenerated) {
182+
errors.foreach { error =>
183+
index.app.reporter.log(Diagnostic.exception(error))
184+
}
182185
CommandResult(1, Nil)
183186
} else {
184187
if (errors.nonEmpty && isSemanticdbGenerated) {
@@ -376,8 +379,9 @@ class LsifBuildTool(index: IndexCommand) extends BuildTool("LSIF", index) {
376379
)(fn: PresentationCompiler => T): T = {
377380
val scalaVersion = deps
378381
.classpath
379-
.headOption
382+
.iterator
380383
.flatMap(jar => ScalaVersion.inferFromJar(jar))
384+
.nextOption()
381385
.getOrElse {
382386
throw new IllegalArgumentException(
383387
s"failed to infer the Scala version from the dependencies: " +

0 commit comments

Comments
 (0)