Skip to content

Commit cce9533

Browse files
committed
Drop user-facing support for ScipBuildTool
ScipBuildTool is now an internal worker dispatched only when the Bazel aspect (scip_java.bzl) invokes 'scip-java index --scip-config <file>'. User-facing changes: - Remove 'index-dependency' subcommand. - Hide --scip-config, --scip-ignored-javac-option-prefixes, --scip-ignored-annotation-processors, and --strict-compilation from 'scip-java index --help'. - Drop the 'SCIP Build Tool' help section and fix the misplaced description on --build-command. - Stop auto-detecting lsif-java.json / scip-java.json files; the only supported build tools advertised to users are Maven and Gradle. - Drop jq from the Dockerfile, Nix flake, dev-shell docs, and the scip-java docker wrapper (it only existed to read lsif-java.json). Internal: - BuildTool.autoOrdered no longer lists ScipBuildTool. - IndexCommand.run() early-returns into ScipBuildTool when --scip-config is provided, keeping the Bazel aspect functional. - ScipBuildTool.usedInCurrentDirectory() always returns false and parsedConfig only reads index.scipConfig. Tests/snapshots: - Remove ScipBuildToolSuite, TracingServer, LibrarySnapshotGenerator, AggregateSnapshotGenerator, SemanticdbJavacSnapshotGenerator, LibrarySnapshotSuite, and the org/jetbrains/exposed snapshot fixtures. - SaveSnapshots and SnapshotSuite are simplified to only drive MinimizedSnapshotScipGenerator.
1 parent 580fbf5 commit cce9533

95 files changed

Lines changed: 51 additions & 86934 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ nix develop .#jdk21 # JDK 21
1515
```
1616

1717
This drops you into a shell with `sbt`, `cs` (coursier), `maven`, `gradle`,
18-
`bazelisk`, `scalafmt`, `nodejs`, `yarn`, `git`, `jq`, etc. all pinned to the
18+
`bazelisk`, `scalafmt`, `nodejs`, `yarn`, `git`, etc. all pinned to the
1919
versions used in CI.
2020

2121
If you'd rather install tools manually, you'll need at least:
@@ -55,7 +55,6 @@ These are the main components of the project.
5555
| `buildTools/test` | sbt | Run slow build tool tests (Gradle, Maven). |
5656
| `snapshots/testOnly tests.MinimizedSnapshotSuite` | sbt | Runs fast snapshot tests. Indexes a small set of files under `tests/minimized`. |
5757
| `snapshots/testOnly tests.MinimizedSnapshotSuite -- *InnerClasses*` | sbt | Runs only individual tests cases matching the name "InnerClasses". |
58-
| `snapshots/testOnly tests.LibrarySnapshotSuite` | sbt | Runs slow snapshot tests. Indexes a corpus of external Java libraries. |
5958
| `snapshots/test` | sbt | Runs all snapshot tests. |
6059
| `snapshots/run` | sbt | Update snapshot tests. Use this command after you have fixed a bug. |
6160
| `cli/run --cwd DIRECTORY` | sbt | Run `scip-java` command-line tool against a given Gradle/Maven build. |

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
FROM eclipse-temurin:17@sha256:6eca72bb4cd5fb8cd215f2579a4dfffd24b0f47effb6c868b7e92b7f0422fa9f
22

3-
RUN apt-get update && apt-get install --yes jq wget curl zip unzip git python3 python3-pip autoconf automake libtool build-essential libtool make g++
3+
RUN apt-get update && apt-get install --yes wget curl zip unzip git python3 python3-pip autoconf automake libtool build-essential libtool make g++
44

55
WORKDIR /workdir
66

bin/scip-java-docker-script.sh

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
# `scip-java` binary is already installed at `/app/scip-java/bin/scip-java`.
55
set -eu
66
JVM_VERSION="${JVM_VERSION:-21,17,11,8}"
7-
FILE="$PWD/lsif-java.json"
8-
if test -f "$FILE"; then
9-
FROM_CONFIG=$(jq -r '.jvm' "$FILE")
10-
if [ "$FROM_CONFIG" != "null" ]; then
11-
JVM_VERSION="$FROM_CONFIG"
12-
fi
13-
fi
147

158
JVM_VERSIONS=$(echo "$JVM_VERSION" | tr "," "\n")
169

flake.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
git
2828
(gradle.override ({ java = jdk; }))
2929
jdk
30-
jq
3130
(maven.override ({ jdk_headless = jdk; }))
3231
nixfmt
3332
nodejs

scip-java/src/main/scala/com/sourcegraph/scip_java/ScipJava.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.sourcegraph.scip_java
33
import java.io.PrintStream
44

55
import com.sourcegraph.scip_java.commands.IndexCommand
6-
import com.sourcegraph.scip_java.commands.IndexDependencyCommand
76
import com.sourcegraph.scip_java.commands.IndexSemanticdbCommand
87
import com.sourcegraph.scip_java.commands.SnapshotCommand
98
import moped.cli.Application
@@ -21,7 +20,6 @@ object ScipJava {
2120
CommandParser[VersionCommand],
2221
CommandParser[IndexCommand],
2322
CommandParser[IndexSemanticdbCommand],
24-
CommandParser[IndexDependencyCommand],
2523
CommandParser[SnapshotCommand]
2624
)
2725
)

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ object BuildTool {
2727
// first detected build tool will be used in `auto` mode
2828
// Bazel is missing because it isn't supported by auto-indexing
2929

30-
// first as it indicates user's intent to use SCIP auto-indexing
31-
new ScipBuildTool(index),
3230
// Maven first, then Gradle
3331
// To match the order indicated in IntelliJ Java developer survey 2022:
3432
// https://www.jetbrains.com/lp/devecosystem-2022/java/#which-build-systems-do-you-regularly-use-if-any-

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

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,27 @@ import os.ProcessOutput.Readlines
5757
import os.SubprocessException
5858

5959
/**
60-
* A custom build tool that is specifically made for scip-java.
60+
* Internal build-tool worker used exclusively by the Bazel aspect.
6161
*
62-
* The purpose of this build tool is to SCIP index the source code inside
63-
* `*-sources.jar` files of Maven dependencies. Builds are written in a JSON
64-
* file with the following format:
62+
* This tool is no longer part of the user-facing build-tool auto-detection
63+
* surface (see [[BuildTool.autoOrdered]]). It is dispatched directly from
64+
* [[com.sourcegraph.scip_java.commands.IndexCommand]] when the hidden
65+
* `--scip-config` flag is provided, which is how the Bazel aspect
66+
* (`scip_java.bzl`) invokes per-target indexing.
67+
*
68+
* The aspect generates a JSON file per Bazel target with the following
69+
* shape and passes its path via `--scip-config`:
6570
*
6671
* {{{
6772
* {
68-
* "dependencies": ["junit:junit:4.13.1"],
69-
* "jvm": "11"
73+
* "javaHome": "/path/to/jdk",
74+
* "classpath": [...],
75+
* "sourceFiles": [...],
76+
* "javacOptions": [...],
77+
* "jvmOptions": [...],
78+
* "processors": [...],
79+
* "processorpath": [...],
80+
* "bootclasspath": [...]
7081
* }
7182
* }}}
7283
*/
@@ -83,9 +94,10 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
8394
.getPathMatcher("glob:**.{java,kt}")
8495
private val moduleInfo = Paths.get("module-info.java")
8596

86-
override def usedInCurrentDirectory(): Boolean = configFiles.exists(path =>
87-
Files.isRegularFile(path)
88-
)
97+
// ScipBuildTool is dispatched directly from IndexCommand.run() when
98+
// --scip-config is provided, so it does not participate in build-tool
99+
// auto-detection.
100+
override def usedInCurrentDirectory(): Boolean = false
89101
override def isHidden: Boolean = true
90102
override def generateScip(): Int = {
91103
BuildTool.generateScipFromTargetroot(
@@ -97,11 +109,6 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
97109

98110
private def targetroot: Path = index.finalTargetroot(defaultTargetroot)
99111
private def defaultTargetroot: Path = Paths.get("target")
100-
private def configFiles =
101-
index.scipConfig.toList ++
102-
ScipBuildTool
103-
.ConfigFileNames
104-
.map(name => index.workingDirectory.resolve(name))
105112
private def generateSemanticdb(): CommandResult = {
106113
parsedConfig match {
107114
case ValueResult(value) =>
@@ -125,14 +132,13 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
125132
}
126133
}
127134

128-
/** Parses the lsif-java.json file into a Config object. */
135+
/** Parses the --scip-config file into a Config object. */
129136
private def parsedConfig: Result[Config] = {
130-
configFiles.find(path => Files.isRegularFile(path)) match {
137+
index.scipConfig.filter(Files.isRegularFile(_)) match {
131138
case None =>
132139
ErrorResult(
133140
Diagnostic.error(
134-
s"no config file found. To fix this problem, create a config file in the path '${configFiles
135-
.head}'"
141+
s"no --scip-config file found at '${index.scipConfig.map(_.toString).getOrElse("")}'"
136142
)
137143
)
138144
case Some(configFile) =>
@@ -635,7 +641,7 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
635641
}
636642

637643
/**
638-
* Gets parsed from "junit:junit:4.13.1" strings inside lsif-java.json files.
644+
* Gets parsed from "junit:junit:4.13.1" strings inside --scip-config files.
639645
*/
640646
private case class Dependency(
641647
groupId: String = "",
@@ -682,7 +688,7 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
682688
}
683689
}
684690

685-
/** Gets parsed from lsif-java.json files. */
691+
/** Gets parsed from --scip-config files. */
686692
private case class Config(
687693
reportWarningOnEmptyIndex: Boolean = true,
688694
javaHome: Option[String] = None,
@@ -704,14 +710,6 @@ class ScipBuildTool(index: IndexCommand) extends BuildTool("SCIP", index) {
704710
}
705711

706712
object ScipBuildTool {
707-
// This file is named "lsif-java.json" instead of "scip-java.json" in order to
708-
// preserve compatibility with "JVM dependencies" repos
709-
// (https://docs.sourcegraph.com/integration/jvm). If we rename to
710-
// "scip-java.json" then the git commit SHAs of these repos changes and old
711-
// canonical URLs will become 404 links. The lsif-java.json file is not
712-
// supposed to be written by end-users anyways. It's mostly an implementation
713-
// default for how we support cross-repo navigation with scip-java.
714-
val ConfigFileNames = List("scip-java.json", "lsif-java.json")
715713
val isIgnoredAnnotationProcessor = Set(
716714
"org.openjdk.jmh.generators.BenchmarkProcessor"
717715
)

scip-java/src/main/scala/com/sourcegraph/scip_java/commands/IndexCommand.scala

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,11 @@ case class IndexCommand(
5656
packagehub: Option[String] = None,
5757
@Hidden // Hidden because it's only used for testing purposes
5858
temporaryDirectory: Option[Path] = None,
59-
@Section("SCIP Build Tool")
60-
@Description(
61-
"List of Java compiler option prefixes that should be excluded from compilation during indexing. " +
62-
"This flag is only used when indexing via scip-java.json files or Bazel."
63-
)
59+
@Hidden // Internal flag used by the Bazel aspect to pass per-target build configuration.
6460
scipIgnoredJavacOptionPrefixes: List[String] = Nil,
65-
@Description(
66-
"List of fully qualified annotation processors that should be ignored when indexing a codebase. " +
67-
"This flag is only used when indexing via scip-java.json files or Bazel."
68-
)
61+
@Hidden // Internal flag used by the Bazel aspect to pass per-target build configuration.
6962
scipIgnoredAnnotationProcessors: List[String] = Nil,
70-
@Description(
71-
"Path to a scip-java.json file with build configuration. By default, the path scip-java.json is used."
72-
)
63+
@Hidden // Internal flag used by the Bazel aspect to pass per-target build configuration.
7364
scipConfig: Option[Path] = None,
7465
@Section("Bazel")
7566
@Description(
@@ -86,15 +77,14 @@ case class IndexCommand(
8677
"If true, automatically tries to extract the printed out sandbox command and re-run the command to reveal the underlying problem."
8778
)
8879
bazelAutorunSandboxCommand: Boolean = true,
80+
@Hidden
81+
@Description("Fail command invocation if compiler produces any errors")
82+
strictCompilation: Boolean = false,
8983
@Description(
9084
"Optional. The build command to use to compile all sources. " +
9185
"Defaults to a build-specific command. For example, the default command for Maven command is 'clean verify -DskipTests'." +
9286
"To override the default, pass in the build command after a double dash: 'scip-java index -- compile test:compile'"
9387
)
94-
95-
@Hidden
96-
@Description("Fail command invocation if compiler produces any errors")
97-
strictCompilation: Boolean = false,
9888
@TrailingArguments()
9989
buildCommand: List[String] = Nil,
10090
@Hidden
@@ -152,6 +142,14 @@ case class IndexCommand(
152142
buildCommand
153143

154144
override def run(): Int = {
145+
// The Bazel aspect invokes `scip-java index --scip-config <file>` for
146+
// every Java target it discovers. When --scip-config is provided we
147+
// bypass build-tool auto-detection entirely and dispatch directly to
148+
// the internal ScipBuildTool worker.
149+
if (scipConfig.isDefined) {
150+
return new ScipBuildTool(this).generateScip()
151+
}
152+
155153
val allBuildTools = BuildTool.all(this)
156154
val usedBuildTools = allBuildTools.filter(_.usedInCurrentDirectory())
157155
val matchingBuildTools = usedBuildTools.filter(tool =>
@@ -172,17 +170,13 @@ case class IndexCommand(
172170
unknownBuildTool(buildTool, usedBuildTools)
173171
case tool :: Nil =>
174172
tool.generateScip()
175-
case many @ (first :: rest) =>
176-
if (first.isInstanceOf[ScipBuildTool] && scipConfig.isDefined) {
177-
first.generateScip()
178-
} else {
179-
val names = many.map(_.name).mkString(", ")
180-
app.error(
181-
s"Multiple build tools detected: $names. " +
182-
s"To fix this problem, use the '--build-tool=BUILD_TOOL_NAME' flag to specify which build tool to run."
183-
)
184-
1
185-
}
173+
case many =>
174+
val names = many.map(_.name).mkString(", ")
175+
app.error(
176+
s"Multiple build tools detected: $names. " +
177+
s"To fix this problem, use the '--build-tool=BUILD_TOOL_NAME' flag to specify which build tool to run."
178+
)
179+
1
186180
}
187181
}
188182
}

0 commit comments

Comments
 (0)