Skip to content

Commit 06c0af4

Browse files
authored
Merge pull request #497 from ckipp01/millJava
2 parents 5a49a8b + 4b44806 commit 06c0af4

File tree

7 files changed

+65
-15
lines changed

7 files changed

+65
-15
lines changed

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ lazy val V =
2424
def testcontainers = "0.39.3"
2525
def requests = "0.6.5"
2626
def minimalMillVersion = "0.10.0"
27-
def millScipVersion = "0.2.3"
27+
def millScipVersion = "0.3.0"
2828
}
2929

3030
inThisBuild(

docs/getting-started.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ free to subscribe to the tracking issues to receive updates on your build tool.
243243
| Ant |||| [sourcegraph/scip-java#305](https://github.com/sourcegraph/scip-java/issues/305) |
244244
| Bazel |||| |
245245
| Buck |||| [sourcegraph/scip-java#99](https://github.com/sourcegraph/scip-java/issues/99) |
246-
| Mill | |||
246+
| Mill | |||
247247

248248
****: automatic indexing is fully supported. Please report a bug if the
249249
`scip-java index` command does not work on your codebase.
@@ -304,9 +304,10 @@ projects, with the following caveats:
304304
The `scip-java index` build should be able to automatically index most Mill
305305
projects, with the following caveats:
306306

307-
| Integration | Supported | Recommendation |
308-
| ------------- | --------- | -------------------------- |
309-
| Mill <v0.10.0 || Upgrade to Mill >= v0.10.0 |
307+
| Integration | Supported | Recommendation |
308+
| ------------- | --------------------| -------------------------------------------|
309+
| Mill <v0.10.0 || Upgrade to Mill >= v0.10.0 |
310+
| Mill <v0.10.6 | Only supports Scala | Upgrade to Mill >= v0.10.6 for Java support|
310311

311312

312313
### Bazel

scip-java/src/main/scala/com/sourcegraph/scip_java/buildtools/MillBuildTool.scala

+8-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ class MillBuildTool(index: IndexCommand) extends BuildTool("mill", index) {
3535
1
3636
}
3737

38+
private val rawOutput = index.output.toString
39+
3840
private def unconditionallyGenerateScip(): Int = {
3941
val localMill = Files.isRegularFile(millFile)
4042
val command =
@@ -46,9 +48,12 @@ class MillBuildTool(index: IndexCommand) extends BuildTool("mill", index) {
4648
val millProcess = index.process(
4749
List(
4850
command,
51+
"--no-server",
4952
"--import",
5053
s"ivy:io.chris-kipp::mill-scip::${BuildInfo.millScipVersion}",
51-
"io.kipp.mill.scip.Scip/generate"
54+
"io.kipp.mill.scip.Scip/generate",
55+
"--output",
56+
rawOutput
5257
)
5358
)
5459
val scipFile = index
@@ -60,10 +65,10 @@ class MillBuildTool(index: IndexCommand) extends BuildTool("mill", index) {
6065
.resolve("scip")
6166
.resolve("Scip")
6267
.resolve("generate.dest")
63-
.resolve("index.scip")
68+
.resolve(rawOutput)
6469

6570
if (millProcess.exitCode == 0 && Files.isRegularFile(scipFile)) {
66-
val output = index.workingDirectory.resolve("index.scip")
71+
val output = index.workingDirectory.resolve(rawOutput)
6772
Files.copy(scipFile, output, StandardCopyOption.REPLACE_EXISTING)
6873
index.app.info(output.toString)
6974
}

semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbJavacOptions.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public static SemanticdbJavacOptions parse(String[] args, Context ctx) {
5555
}
5656
} else if (arg.startsWith("-sourceroot:")) {
5757
result.sourceroot = Paths.get(arg.substring("-sourceroot:".length())).normalize();
58-
} else if (arg.equals("-build-tool:sbt")) {
59-
result.uriScheme = UriScheme.SBT;
58+
} else if (arg.equals("-build-tool:sbt") || args.equals("-build-tool:mill")) {
59+
result.uriScheme = UriScheme.ZINC;
6060
} else if (arg.equals("-build-tool:bazel")) {
6161
result.uriScheme = UriScheme.BAZEL;
6262
useJavacClassesDir = true;

semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/SemanticdbTaskListener.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private void writeSemanticdb(TaskEvent event, Path output, Semanticdb.TextDocume
102102

103103
public static Path absolutePathFromUri(SemanticdbJavacOptions options, JavaFileObject file) {
104104
URI uri = file.toUri();
105-
if (options.uriScheme == UriScheme.SBT
105+
if ((options.uriScheme == UriScheme.SBT || options.uriScheme == UriScheme.ZINC)
106106
&& uri.getScheme().equals("vf")
107107
&& uri.toString().startsWith("vf://tmp/")) {
108108
String[] parts = uri.toString().split("/", 5);

semanticdb-javac/src/main/java/com/sourcegraph/semanticdb_javac/UriScheme.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
public enum UriScheme {
44
DEFAULT,
5+
/** @deprecated Use ZINC instead */
6+
@Deprecated
57
SBT,
6-
BAZEL
8+
BAZEL,
9+
ZINC
710
}

tests/buildTools/src/test/scala/tests/MillBuildToolSuite.scala

+44-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import scala.jdk.CollectionConverters._
99

1010
class MillBuildToolSuite extends BaseBuildToolSuite {
1111

12-
def setupMill() = {
12+
def setupMill(millVersion: String) = {
1313
val mill = workingDirectory.resolve("mill")
1414
val resource = getClass().getResource("/mill")
1515
val in = Paths.get(resource.toURI)
@@ -24,7 +24,7 @@ class MillBuildToolSuite extends BaseBuildToolSuite {
2424
PosixFilePermission.OWNER_EXECUTE
2525
).asJava
2626
)
27-
List("./mill", "--version")
27+
List("./mill", s"--mill-version", millVersion, "--version")
2828
}
2929

3030
def scalaLibrary(scalaVersion: String) =
@@ -92,8 +92,49 @@ class MillBuildToolSuite extends BaseBuildToolSuite {
9292
|maven:org.scalameta:junit-interface:1.0.0-M6
9393
|maven:org.scalameta:munit_${scalaBinaryVersion(scalaVersion)}:1.0.0-M6
9494
|""".stripMargin,
95-
initCommand = setupMill(),
95+
initCommand = setupMill(millVersion),
9696
targetRoot = Some("out/io/kipp/mill/scip/Scip/generate.dest")
9797
)
9898
}
99+
100+
checkBuild(
101+
"java-module",
102+
s"""|/.mill-version
103+
|0.10.7
104+
|/build.sc
105+
|import mill._, scalalib._
106+
|object minimal extends JavaModule
107+
|/minimal/src/ScipOutputFormat.java
108+
|package minimal;
109+
|public enum ScipOutputFormat {
110+
| GRAPH_NDJSON,
111+
| GRAPH_PROTOBUF,
112+
| TYPED_PROTOBUF,
113+
| TYPED_NDJSON,
114+
| UNKNOWN;
115+
|}
116+
|""".stripMargin,
117+
expectedSemanticdbFiles = 1,
118+
initCommand = setupMill("0.10.7"),
119+
targetRoot = Some("out/io/kipp/mill/scip/Scip/generate.dest")
120+
)
121+
122+
checkBuild(
123+
"lsif-output",
124+
s"""|/.mill-version
125+
|0.10.7
126+
|/build.sc
127+
|import mill._, scalalib._
128+
|object minimal extends ScalaModule {
129+
| def scalaVersion = "3.1.3"
130+
|}
131+
|/minimal/src/Main.scala
132+
|package minimal
133+
|@main def hello = ()
134+
|""".stripMargin,
135+
expectedSemanticdbFiles = 1,
136+
initCommand = setupMill("0.10.7"),
137+
targetRoot = Some("out/io/kipp/mill/scip/Scip/generate.dest"),
138+
extraArguments = List("--output", "dump.lsif")
139+
)
99140
}

0 commit comments

Comments
 (0)