Skip to content

Commit

Permalink
feat: allow scip-java index --output to work for Mill
Browse files Browse the repository at this point in the history
This ensures that when a user uses `scip-java` with the output flag
like:
```
scip-java index --output dump.lsif
```
Then this gets forwarded to Mill to ensure it creates an lsif file not a
scip one.

refs: sourcegraph#482
  • Loading branch information
ckipp01 committed Aug 25, 2022
1 parent 229e429 commit b6bd159
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class MillBuildTool(index: IndexCommand) extends BuildTool("mill", index) {
1
}

private val rawOutput = index.output.toString

private def unconditionallyGenerateScip(): Int = {
val localMill = Files.isRegularFile(millFile)
val command =
Expand All @@ -48,7 +50,9 @@ class MillBuildTool(index: IndexCommand) extends BuildTool("mill", index) {
command,
"--import",
s"ivy:io.chris-kipp::mill-scip::${BuildInfo.millScipVersion}",
"io.kipp.mill.scip.Scip/generate"
"io.kipp.mill.scip.Scip/generate",
"--output",
rawOutput
)
)
val scipFile = index
Expand All @@ -60,10 +64,10 @@ class MillBuildTool(index: IndexCommand) extends BuildTool("mill", index) {
.resolve("scip")
.resolve("Scip")
.resolve("generate.dest")
.resolve("index.scip")
.resolve(rawOutput)

if (millProcess.exitCode == 0 && Files.isRegularFile(scipFile)) {
val output = index.workingDirectory.resolve("index.scip")
val output = index.workingDirectory.resolve(rawOutput)
Files.copy(scipFile, output, StandardCopyOption.REPLACE_EXISTING)
index.app.info(output.toString)
}
Expand Down
19 changes: 19 additions & 0 deletions tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,23 @@ class MillBuildToolSuite extends BaseBuildToolSuite {
initCommand = setupMill("0.10.7"),
targetRoot = Some("out/io/kipp/mill/scip/Scip/generate.dest")
)

checkBuild(
"lsif-output",
s"""|/.mill-version
|0.10.7
|/build.sc
|import mill._, scalalib._
|object minimal extends ScalaModule {
| def scalaVersion = "3.1.3"
|}
|/minimal/src/Main.scala
|package minimal
|@main def hello = ()
|""".stripMargin,
expectedSemanticdbFiles = 1,
initCommand = setupMill("0.10.7"),
targetRoot = Some("out/io/kipp/mill/scip/Scip/generate.dest"),
extraArguments = List("--output", "dump.lsif")
)
}

0 comments on commit b6bd159

Please sign in to comment.