diff --git a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/SbtBuildTool.scala b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/SbtBuildTool.scala index bc2d6ee1..4633bc92 100644 --- a/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/SbtBuildTool.scala +++ b/scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/SbtBuildTool.scala @@ -43,13 +43,17 @@ class SbtBuildTool(index: IndexCommand) extends BuildTool("sbt", index) { private def unconditionallyGenerateScip(): Int = Using.resource(sourcegraphSbtPluginFile()) { _ => + val buildCommand = index.finalBuildCommand(List("sourcegraphScip")) + val sourcegraphScip = index - .process(List("sbt", "sourcegraphEnable", "sourcegraphScip")) + .process(List("sbt", "sourcegraphEnable") ++ buildCommand) + val inputDump = index .workingDirectory .resolve("target") .resolve("sbt-sourcegraph") .resolve("index.scip") + if (sourcegraphScip.exitCode == 0 && Files.isRegularFile(inputDump)) { val outputDump = index.workingDirectory.resolve(index.output) Files.copy(inputDump, outputDump, StandardCopyOption.REPLACE_EXISTING) diff --git a/tests/buildTools/src/test/scala/tests/SbtBuildToolSuite.scala b/tests/buildTools/src/test/scala/tests/SbtBuildToolSuite.scala index 9eea1f6f..2f97a72f 100644 --- a/tests/buildTools/src/test/scala/tests/SbtBuildToolSuite.scala +++ b/tests/buildTools/src/test/scala/tests/SbtBuildToolSuite.scala @@ -1,15 +1,18 @@ package tests -abstract class SbtBuildToolSuite(sbtVersion: String) +abstract class SbtBuildToolSuite(val sbtVersion: String) extends BaseBuildToolSuite { - List("2.11.9", "2.12.18", "2.13.11", "3.3.0").foreach { scalaVersion => + val scala2Versions = List("2.11.9", "2.12.18", "2.13.11") + val scala3Versions = List("3.3.1") + + (scala2Versions ++ scala3Versions).foreach { scalaVersion => checkBuild( s"basic-sbt=$sbtVersion-scala=$scalaVersion", s"""|/build.sbt |scalaVersion := "$scalaVersion" |libraryDependencies += "junit" % "junit" % "4.13.2" |/project/build.properties - |sbt.version=1.5.2 + |sbt.version=$sbtVersion |/src/main/java/example/ExampleJava.java |package example; |import org.junit.Assert; @@ -29,8 +32,27 @@ abstract class SbtBuildToolSuite(sbtVersion: String) targetRoot = Some("target") ) } - } -class Sbt_1_BuildToolSuite extends SbtBuildToolSuite("1.5.2") -class Sbt_013_BuildToolSuite extends SbtBuildToolSuite("0.13.17") +class Sbt_1_BuildToolSuite extends SbtBuildToolSuite("1.5.2") { + checkBuild( + s"custom-sbt-command=$sbtVersion", + s"""|/build.sbt + |lazy val bla = project.in(file("bla")) + |lazy val blaJS = project.in(file("bla-js")).enablePlugins(ScalaJSPlugin) + |/project/plugins.sbt + |addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.14.0") + |/project/build.properties + |sbt.version=$sbtVersion + |/bla/src/main/scala/example/ExampleScala.scala + |package example + |class ExampleScala() + |/bla-js/src/main/scala/example/ExampleScala.scala + |package example + |class ExampleScala!!!() // this file is intentionally broken + |""".stripMargin, + expectedSemanticdbFiles = 1, + extraArguments = List("--", "bla/compile"), + targetRoot = Some("bla/target") + ) +}