From 684ed9b6c1e8d9c008817e48e0d0b478606a132d Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 23 Jun 2026 13:08:35 +0200 Subject: [PATCH 1/9] Remove unused Scala build tooling --- .github/workflows/ci.yml | 14 -------------- .jvmopts | 4 ---- .scalafix.conf | 15 --------------- .scalafmt.conf | 12 ------------ CONTRIBUTING.md | 7 ++----- build.sbt | 26 +++----------------------- flake.nix | 14 -------------- project/plugins.sbt | 6 ------ 8 files changed, 5 insertions(+), 93 deletions(-) delete mode 100644 .jvmopts delete mode 100644 .scalafix.conf delete mode 100644 .scalafmt.conf diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d39e56eb..6b1100b14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -129,20 +129,6 @@ jobs: git diff --exit-code \ scip-kotlinc/minimized/src/generatedSnapshots - check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: DeterminateSystems/nix-installer-action@v22 - with: - summarize: false - - - uses: DeterminateSystems/magic-nix-cache-action@v13 - - - run: nix develop --command sbt --client checkAll - - maven: runs-on: ubuntu-latest name: Maven tests diff --git a/.jvmopts b/.jvmopts deleted file mode 100644 index cc6fa202e..000000000 --- a/.jvmopts +++ /dev/null @@ -1,4 +0,0 @@ --Xss2m --Xms1G --Xmx4G --Dfile.encoding=UTF-8 diff --git a/.scalafix.conf b/.scalafix.conf deleted file mode 100644 index b6b7aabf4..000000000 --- a/.scalafix.conf +++ /dev/null @@ -1,15 +0,0 @@ -rules = [ - OrganizeImports, -] - -ExplicitResultTypes.rewriteStructuralTypesToNamedSubclass = false - -OrganizeImports.groupedImports = Explode -OrganizeImports.expandRelative = true -OrganizeImports.removeUnused = true -OrganizeImports.groups = [ - "re:javax?\\." - "scala." - "scala.meta." - "*" -] diff --git a/.scalafmt.conf b/.scalafmt.conf deleted file mode 100644 index 0075655f0..000000000 --- a/.scalafmt.conf +++ /dev/null @@ -1,12 +0,0 @@ -version = "3.11.1" -runner.dialect = scala213source3 -assumeStandardLibraryStripMargin = true -docstrings.style = Asterisk -docstrings.wrap = "yes" -project.git = true -align.preset = none -align.stripMargin = true -newlines.source=unfold -project.excludeFilters = [ - "tests/snapshots/src/main/generated" -] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f69c929b9..a2c56b723 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,8 +15,7 @@ nix develop .#jdk21 # JDK 21 ``` This drops you into a shell with `sbt`, `maven`, `gradle`, `bazelisk`, -`scalafmt`, `nodejs`, `yarn`, `git`, `jq`, etc. all pinned to the versions used -in CI. +`nodejs`, `yarn`, `git`, `jq`, etc. all pinned to the versions used in CI. If you'd rather install tools manually, you'll need at least: @@ -40,7 +39,7 @@ These are the main components of the project. - `tests/snapshots`: slow running ["snapshot tests"](https://jestjs.io/docs/en/snapshot-testing) that index a corpus of published Java libraries. -- `cli/src/main/scala`: implementation of the `scip-java` command-line +- `scip-java/src/main/kotlin`: implementation of the `scip-java` command-line interface. - `build.sbt`: the sbt build definition. - `project/plugins.sbt`: plugins for the sbt build. @@ -59,7 +58,6 @@ These are the main components of the project. | `scipKotlincMinimized/kotlincSnapshots` | sbt | Update only the Kotlin snapshot goldens under `scip-kotlinc/minimized`. | | `regenerateSnapshots` | sbt | Regenerate ALL snapshot goldens (Java + Kotlin). Run after fixing a bug. | | `cli/run --cwd DIRECTORY` | sbt | Run `scip-java` command-line tool against a given Gradle/Maven build. | -| `fixAll` | sbt | Run Scalafmt and Scalafix on all Scala sources. Run this before opening a PR. | | `google-java-format --replace $(git ls-files '*.java')` | terminal | Format Java sources (from `nix develop`). Enforced by `nix flake check`. | | `ktfmt --kotlinlang-style $(git ls-files '*.kt')` | terminal | Format Kotlin sources (from `nix develop`). Enforced by `nix flake check`. | @@ -74,7 +72,6 @@ community edition is Next, install the following IntelliJ plugins: -- IntelliJ Scala plugin. - Google Java Format Next, follow diff --git a/build.sbt b/build.sbt index f43b619a6..c586513ad 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,6 @@ import _root_.kotlin.Keys._ import scala.xml.{Node => XmlNode, NodeSeq => XmlNodeSeq, _} import scala.xml.transform.{RewriteRule, RuleTransformer} import java.io.File -import java.nio.file.Files import java.util.Properties import scala.collection.mutable.ListBuffer @@ -10,10 +9,7 @@ lazy val V = new { val protobuf = "4.34.2" val scipBindings = "0.8.0" - val scalaXml = "2.1.0" val gradle = "8.10" - val scala213 = "2.13.13" - val scalameta = "4.9.3" val kotlinVersion = "2.2.0" val kotest = "4.6.3" val kctfork = "0.7.1" @@ -30,10 +26,6 @@ else inThisBuild( List( - scalaVersion := V.scala213, - scalacOptions ++= List("-Wunused:imports"), - semanticdbEnabled := true, - semanticdbVersion := V.scalameta, organization := "com.sourcegraph", homepage := Some(url("https://github.com/sourcegraph/scip-java")), dynverSeparator := "-", @@ -61,17 +53,6 @@ inThisBuild( name := "root" (publish / skip) := true -commands += - Command.command("fixAll") { s => - "scalafixAll" :: "scalafmtAll" :: "scalafmtSbt" :: s - } - -commands += - Command.command("checkAll") { s => - "scalafmtCheckAll" :: "scalafmtSbtCheck" :: "scalafixAll --check" :: - "publishLocal" :: s - } - commands += Command.command("regenerateSnapshots") { s => "snapshots/run" :: "scipKotlincMinimized/kotlincSnapshots" :: s @@ -611,10 +592,9 @@ lazy val javaTestSettings = List[Def.Setting[_]]( JupiterKeys.jupiterVersion.value % Test ) -// Runtime paths for the snapshot generator, passed as -D system properties -// (replacing the former sbt-buildinfo values). Depending on `minimized/compile` -// here guarantees a fresh targetroot whenever `snapshots/test` or `snapshots/run` -// evaluate javaOptions. +// Runtime paths for the snapshot generator, passed as -D system properties. +// Depending on `minimized/compile` here guarantees a fresh targetroot whenever +// `snapshots/test` or `snapshots/run` evaluate javaOptions. def snapshotPathOptions = Def.task { val _ = (minimized / Compile / compile).value Seq( diff --git a/flake.nix b/flake.nix index 82f697ad6..24c755c8a 100644 --- a/flake.nix +++ b/flake.nix @@ -38,7 +38,6 @@ nixfmt nodejs (sbt.override ({ jre = jdk; })) - scalafmt scipCli yarn ]; @@ -85,19 +84,6 @@ ${./.github/renovate.json} touch $out ''; - scalafmt = - pkgs.runCommand "check-scalafmt" - { - buildInputs = [ pkgs.git ]; - } - '' - cp -r ${./.}/. . - chmod -R u+w . - git init -q - git add -A - ${pkgs.scalafmt}/bin/scalafmt --check --non-interactive - touch $out - ''; shellcheck = pkgs.runCommand "check-shellcheck" { } '' ${pkgs.shellcheck}/bin/shellcheck ${./bin}/*.sh touch $out diff --git a/project/plugins.sbt b/project/plugins.sbt index 7abe11a2d..d2dd6e610 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,16 +1,10 @@ addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.14") addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.11.0") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.1") -addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.10.0") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.5") -addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.14.3") addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % "3.1.6") addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.15.1") -// sbt-jdi-tools appears to fix an error related to this message: -// [error] (plugin / Compile / compileIncremental) java.lang.NoClassDefFoundError: com/sun/tools/javac/code/Symbol -addSbtPlugin("org.scala-debugger" % "sbt-jdi-tools" % "1.1.1") ThisBuild / libraryDependencySchemes ++= Seq("org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always) From c8e194d6848b28c133ed26460a4efca0b21a1194 Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 23 Jun 2026 13:35:27 +0200 Subject: [PATCH 2/9] Use direct Docker builds --- .github/workflows/ci.yml | 8 +------- .github/workflows/release-docker.yml | 21 ++++++++++++++++----- build.sbt | 28 ++-------------------------- project/plugins.sbt | 1 - 4 files changed, 19 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b1100b14..52a0b0cf8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,14 +30,8 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@v22 - with: - summarize: false - - - uses: DeterminateSystems/magic-nix-cache-action@v13 - - name: Build Dockerised CLI - run: nix develop --command bash -c "DOCKER_BUILDKIT=0 sbt cli/docker" + run: docker build -t sourcegraph/scip-java:latest . - name: Test repos shell: bash diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index ed93824e3..eb37ca8f9 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -11,14 +11,25 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: DeterminateSystems/nix-installer-action@v22 - with: - summarize: false - - uses: DeterminateSystems/magic-nix-cache-action@v13 - uses: docker/setup-buildx-action@v3 - name: Login to DockerHub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - run: nix develop --command bash -c "DOCKER_BUILDKIT=0 sbt cli/dockerBuildAndPush" + - name: Build and push Docker image + shell: bash + run: | + set -euo pipefail + + tags=(--tag sourcegraph/scip-java:latest-snapshot) + + if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then + version="${GITHUB_REF_NAME#v}" + tags=( + --tag sourcegraph/scip-java:latest + --tag "sourcegraph/scip-java:${version}" + ) + fi + + docker buildx build --push "${tags[@]}" . diff --git a/build.sbt b/build.sbt index c586513ad..426b6c616 100644 --- a/build.sbt +++ b/build.sbt @@ -184,7 +184,7 @@ lazy val mavenPlugin = project lazy val cli = project .in(file("scip-java")) - .enablePlugins(KotlinPlugin, PackPlugin, DockerPlugin) + .enablePlugins(KotlinPlugin, PackPlugin) .settings( moduleName := "scip-java", crossPaths := false, @@ -250,31 +250,7 @@ lazy val cli = project propsFile :: copiedJars.toList } - .taskValue, - docker / imageNames := { - val latest = { - val label = - if (isSnapshot.value) - "latest-snapshot" - else - "latest" - - List(ImageName(s"sourcegraph/scip-java:$label")) - } - - // Don't publish a separately tagged image for snapshots - - // only latest-snapshot - val versioned = - if (isSnapshot.value) - Nil - else - List(ImageName(s"sourcegraph/scip-java:${version.value}")) - - latest ++ versioned - - }, - docker / dockerfile := - NativeDockerfile((ThisBuild / baseDirectory).value / "Dockerfile") + .taskValue ) .dependsOn(scip) diff --git a/project/plugins.sbt b/project/plugins.sbt index d2dd6e610..4648234a6 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,5 +1,4 @@ addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.14") -addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.11.0") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.1") addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") From 5c144c046399ff978fd3f23597e275012a6e569c Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 23 Jun 2026 13:45:11 +0200 Subject: [PATCH 3/9] Simplify assembly usage --- build.sbt | 107 +++++++++++++----------------------------------------- 1 file changed, 26 insertions(+), 81 deletions(-) diff --git a/build.sbt b/build.sbt index 426b6c616..2e83248f6 100644 --- a/build.sbt +++ b/build.sbt @@ -1,9 +1,6 @@ import _root_.kotlin.Keys._ -import scala.xml.{Node => XmlNode, NodeSeq => XmlNodeSeq, _} -import scala.xml.transform.{RewriteRule, RuleTransformer} import java.io.File import java.util.Properties -import scala.collection.mutable.ListBuffer lazy val V = new { @@ -86,7 +83,6 @@ lazy val gradlePlugin = project lazy val javacPlugin = project .in(file("scip-javac")) .settings( - fatjarPackageSettings, javaOnlySettings, moduleName := "scip-javac", // Scoped to compile so doc tasks (which reject -g) are unaffected. @@ -99,6 +95,19 @@ lazy val javacPlugin = project IO.createDirectory(empty) Seq("-processorpath", empty.getAbsolutePath) }, + (assembly / assemblyMergeStrategy) := { + case PathList("javax", _ @_*) => + MergeStrategy.discard + case PathList("com", "sun", _ @_*) => + MergeStrategy.discard + case PathList("sun", _ @_*) => + MergeStrategy.discard + case PathList("META-INF", "versions", "9", "module-info.class") => + MergeStrategy.discard + case x => + val oldStrategy = (assembly / assemblyMergeStrategy).value + oldStrategy(x) + }, (assembly / assemblyShadeRules) := Seq( ShadeRule @@ -214,21 +223,16 @@ lazy val cli = project (Compile / resourceGenerators) += Def .task[Seq[File]] { - val outs = ListBuffer.empty[(File, File)] val out = (Compile / resourceManaged).value.toPath IO.delete(out.toFile) - def addJar(jar: File, filename: String): Unit = { - outs += jar -> out.resolve(filename).toFile - } - addJar( - (javacPlugin / Compile / Keys.`package`).value, - "scip-plugin.jar" - ) - addJar((gradlePlugin / Compile / assembly).value, "gradle-plugin.jar") - addJar( - (scipKotlinc / Compile / Keys.`package`).value, - "scip-kotlinc.jar" + val outs = Seq( + (javacPlugin / Compile / assembly).value -> + out.resolve("scip-plugin.jar").toFile, + (gradlePlugin / Compile / assembly).value -> + out.resolve("gradle-plugin.jar").toFile, + (scipKotlinc / Compile / assembly).value -> + out.resolve("scip-kotlinc.jar").toFile ) IO.copy( @@ -239,16 +243,14 @@ lazy val cli = project ) val props = new Properties() val propsFile = out.resolve("scip-java.properties").toFile - val copiedJars = outs.collect { case (_, out) => - out - } + val copiedJars = outs.map { case (_, out) => out } val names = copiedJars.map(_.getName).mkString(";") props.put("jarNames", names) // Build version consumed at runtime by BuildInfo.version (Kotlin). props.put("version", version.value) IO.write(props, "scip-java", propsFile) - propsFile :: copiedJars.toList + propsFile +: copiedJars } .taskValue ) @@ -297,9 +299,8 @@ lazy val scipKotlinc = project libraryDependencies += "org.jetbrains.kotlin" % "kotlin-compiler-embeddable" % V.kotlinVersion % Provided, // ---- sbt-assembly fat-jar --------------------------------------------- - // Mirrors scip-java's `fatjarPackageSettings`. Produces a shaded jar that - // replaces the slim `packageBin` so `publishLocal` ships the shaded - // artifact (the same artifact Gradle's shadowJar produced previously). + // Produces a shaded jar for consumers that need a self-contained compiler + // plugin, such as the CLI resource embedding and minimized fixture build. assembly / assemblyShadeRules := Seq( // Relocate any IntelliJ classes the same way kotlin-compiler-embeddable @@ -309,20 +310,6 @@ lazy val scipKotlinc = project .rename("com.intellij.**" -> "org.jetbrains.kotlin.com.intellij.@1") .inAll ), - Compile / packageBin := assembly.value, - // Strip every from the POM — the fat-jar absorbs the - // protobuf runtime, and the kotlin-* deps are Provided by kotlinc. - pomPostProcess := { node => - new RuleTransformer( - new RewriteRule { - override def transform(n: XmlNode): XmlNodeSeq = - if (n.label == "dependency") - XmlNodeSeq.Empty - else - n - } - ).transform(node).head - }, // tests libraryDependencies ++= Seq( @@ -403,11 +390,11 @@ lazy val scipKotlincMinimized = project // don't have to predict the assembled jar's filename. The .value reference // also gives us the right task ordering — assembly runs before compile. Compile / unmanagedJars += - Attributed.blank((scipKotlinc / Compile / packageBin).value), + Attributed.blank((scipKotlinc / Compile / assembly).value), // Wire the locally-built scip-javac fat jar in place of fetching the // published `com.sourcegraph:scip-javac` artifact at compile time. Compile / unmanagedJars += - Attributed.blank((javacPlugin / Compile / Keys.`package`).value), + Attributed.blank((javacPlugin / Compile / assembly).value), Compile / kotlincPluginOptions ++= { val srcRoot = (ThisBuild / baseDirectory).value.getAbsolutePath val tgtRoot = (target.value / "scip-targetroot").getAbsolutePath @@ -585,48 +572,6 @@ def snapshotPathOptions = Def.task { ) } -lazy val fatjarPackageSettings = List[Def.Setting[_]]( - (assembly / assemblyMergeStrategy) := { - case PathList("javax", _ @_*) => - MergeStrategy.discard - case PathList("com", "sun", _ @_*) => - MergeStrategy.discard - case PathList("sun", _ @_*) => - MergeStrategy.discard - case PathList("META-INF", "versions", "9", "module-info.class") => - MergeStrategy.discard - case x => - val oldStrategy = (assembly / assemblyMergeStrategy).value - oldStrategy(x) - }, - (Compile / Keys.`package`) := { - assembly.value - }, - (Compile / packageBin / packagedArtifact) := { - val (artifact, _) = (Compile / packageBin / packagedArtifact).value - (artifact, assembly.value) - }, - pomPostProcess := { node => - new RuleTransformer( - new RewriteRule { - private def isAbsorbedDependency(node: XmlNode): Boolean = { - node.label == "dependency" && - node.child.exists(child => child.label == "artifactId") - } - override def transform(node: XmlNode): XmlNodeSeq = - node match { - case e: Elem if isAbsorbedDependency(node) => - Comment( - "the dependency that was here has been absorbed via sbt-assembly" - ) - case _ => - node - } - } - ).transform(node).head - } -) - lazy val dumpScipJavaVersion = taskKey[Unit]( "Dump the version of scip-java tool to a VERSION file" ) From 84921cdfcd473d3e3b0c9d13717a40823f24da40 Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 23 Jun 2026 14:00:51 +0200 Subject: [PATCH 4/9] Simplify pack workflow --- .github/workflows/ci.yml | 11 ++++++----- Dockerfile | 3 +-- bin/scip-java-docker-script.sh | 2 +- build.sbt | 34 ++-------------------------------- project/plugins.sbt | 5 +---- 5 files changed, 11 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52a0b0cf8..979804052 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,8 +83,8 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v13 - - run: nix develop --command sbt build - - run: echo "$PWD/out/bin" >> "$GITHUB_PATH" + - run: nix develop --command sbt cli/pack + - run: echo "$PWD/scip-java/target/pack/bin" >> "$GITHUB_PATH" - name: Auto-index scip-java codebase run: | # shellcheck disable=SC2016 @@ -140,9 +140,10 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v13 - run: | - nix develop .#jdk${{ matrix.java }} --command sbt build publishM2 publishLocal dumpScipJavaVersion - echo "SCIP_JAVA_VERSION=$(cat VERSION)" >> "$GITHUB_ENV" - echo "SCIP_JAVA_CLI=$PWD/out/bin/scip-java" >> "$GITHUB_ENV" + nix develop .#jdk${{ matrix.java }} --command sbt cli/pack publishM2 publishLocal + SCIP_JAVA_VERSION="$(nix develop .#jdk${{ matrix.java }} --command sbt --error 'print cli/version')" + printf 'SCIP_JAVA_VERSION=%s\n' "$SCIP_JAVA_VERSION" >> "$GITHUB_ENV" + printf 'SCIP_JAVA_CLI=%s\n' "$PWD/scip-java/target/pack/bin/scip-java" >> "$GITHUB_ENV" - run: | nix develop "$GITHUB_WORKSPACE#jdk${{ matrix.java }}" --command \ diff --git a/Dockerfile b/Dockerfile index 149a2e316..5af452423 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,8 +17,7 @@ RUN git config --global --add safe.directory * COPY . . -RUN sbt publishLocal dumpScipJavaVersion -RUN mkdir -p /app && coursier bootstrap "com.sourcegraph:scip-java:$(cat VERSION)" -f -o /app/scip-java -M com.sourcegraph.scip_java.ScipJava +RUN sbt cli/pack && mkdir -p /app/scip-java && cp -R scip-java/target/pack/. /app/scip-java/ COPY ./bin/scip-java-docker-script.sh /usr/bin/scip-java diff --git a/bin/scip-java-docker-script.sh b/bin/scip-java-docker-script.sh index 68a611c2f..b4478b813 100755 --- a/bin/scip-java-docker-script.sh +++ b/bin/scip-java-docker-script.sh @@ -29,7 +29,7 @@ do eval "$(coursier java --jvm "$JVM_VERSION" --env --jvm-index https://github.com/coursier/jvm-index/blob/master/index.json)" java -version - if /app/scip-java "$@"; then + if /app/scip-java/bin/scip-java "$@"; then LAST_CODE="0" else LAST_CODE=$? diff --git a/build.sbt b/build.sbt index 2e83248f6..79f8f2d86 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,4 @@ import _root_.kotlin.Keys._ -import java.io.File -import java.util.Properties lazy val V = new { @@ -50,11 +48,6 @@ inThisBuild( name := "root" (publish / skip) := true -commands += - Command.command("regenerateSnapshots") { s => - "snapshots/run" :: "scipKotlincMinimized/kotlincSnapshots" :: s - } - // Shared module with the SCIP shard utilities (symbol encoder, document // builder, on-disk writer) consumed by both the Java compiler plugin // (scip-javac) and the Kotlin compiler plugin (scip-kotlinc). @@ -222,7 +215,7 @@ lazy val cli = project ), (Compile / resourceGenerators) += Def - .task[Seq[File]] { + .task { val out = (Compile / resourceManaged).value.toPath IO.delete(out.toFile) @@ -241,14 +234,10 @@ lazy val cli = project preserveLastModified = false, preserveExecutable = true ) - val props = new Properties() val propsFile = out.resolve("scip-java.properties").toFile val copiedJars = outs.map { case (_, out) => out } - val names = copiedJars.map(_.getName).mkString(";") - props.put("jarNames", names) // Build version consumed at runtime by BuildInfo.version (Kotlin). - props.put("version", version.value) - IO.write(props, "scip-java", propsFile) + IO.write(propsFile, s"version=${version.value}\n") propsFile +: copiedJars } @@ -571,22 +560,3 @@ def snapshotPathOptions = Def.task { .getAbsolutePath}" ) } - -lazy val dumpScipJavaVersion = taskKey[Unit]( - "Dump the version of scip-java tool to a VERSION file" -) -dumpScipJavaVersion := { - val versionValue = (cli / version).value - - IO.write((ThisBuild / baseDirectory).value / "VERSION", versionValue) -} - -lazy val build = taskKey[Unit]( - "Build `scip-java` CLI and place it in the out/bin/scip-java. " -) - -build := { - val source = (cli / pack).value - val destination = (ThisBuild / baseDirectory).value / "out" - IO.copyDirectory(source, destination) -} diff --git a/project/plugins.sbt b/project/plugins.sbt index 4648234a6..b098a7edd 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,6 @@ -addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.14") +addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.16") addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.11.1") addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.6") addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.15.0") addSbtPlugin("org.jetbrains.scala" % "sbt-kotlin-plugin" % "3.1.6") addSbtPlugin("com.github.sbt.junit" % "sbt-jupiter-interface" % "0.15.1") - -ThisBuild / libraryDependencySchemes ++= - Seq("org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always) From 630f48dc3bb05a3fb22e87a568c6763b4fd45ecc Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 23 Jun 2026 14:14:29 +0200 Subject: [PATCH 5/9] Simplify shared sbt settings --- build.sbt | 110 +++++++++++++++++++----------------------------------- 1 file changed, 38 insertions(+), 72 deletions(-) diff --git a/build.sbt b/build.sbt index 79f8f2d86..6a48ac152 100644 --- a/build.sbt +++ b/build.sbt @@ -25,6 +25,13 @@ inThisBuild( homepage := Some(url("https://github.com/sourcegraph/scip-java")), dynverSeparator := "-", PB.protocVersion := V.protobuf, + autoScalaLibrary := false, + crossPaths := false, + // Pin bytecode to major 55 so sbt-assembly's older ASM can shade it. + Compile / javacOptions ++= Seq("--release", "11"), + incOptions ~= { old => + old.withEnabled(false).withApiDebug(true) + }, licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), developers := @@ -55,7 +62,6 @@ lazy val scipShared = project .in(file("scip-shared")) .settings( moduleName := "scip-shared", - javaOnlySettings, libraryDependencies += "org.scip-code" % "scip-java-bindings" % V.scipBindings ) @@ -64,7 +70,6 @@ lazy val gradlePlugin = project .in(file("scip-gradle-plugin")) .settings( name := "scip-gradle", - javaOnlySettings, publish / skip := true, libraryDependencies ++= List( @@ -76,7 +81,6 @@ lazy val gradlePlugin = project lazy val javacPlugin = project .in(file("scip-javac")) .settings( - javaOnlySettings, moduleName := "scip-javac", // Scoped to compile so doc tasks (which reject -g) are unaffected. Compile / compile / javacOptions += "-g", @@ -138,9 +142,7 @@ lazy val javacPlugin = project lazy val scip = project .in(file("scip-aggregator")) .settings( - publishMavenStyle := true, moduleName := "scip-aggregator", - javaOnlySettings, libraryDependencies ++= Seq( "org.scip-code" % "scip-java-bindings" % V.scipBindings, @@ -159,7 +161,6 @@ lazy val mavenPlugin = project .in(file("scip-maven-plugin")) .settings( moduleName := "scip-maven-plugin", - javaOnlySettings, libraryDependencies ++= Seq( "org.apache.maven" % "maven-plugin-api" % "3.6.3", @@ -189,11 +190,8 @@ lazy val cli = project .enablePlugins(KotlinPlugin, PackPlugin) .settings( moduleName := "scip-java", - crossPaths := false, - autoScalaLibrary := false, kotlinVersion := V.kotlinVersion, kotlincJvmTarget := "11", - Compile / javacOptions ++= Seq("--release", "11"), (Compile / mainClass) := Some("com.sourcegraph.scip_java.ScipJava"), (run / baseDirectory) := (ThisBuild / baseDirectory).value, // ScipJava.main can call System.exit, so we always fork the JVM when @@ -235,11 +233,10 @@ lazy val cli = project preserveExecutable = true ) val propsFile = out.resolve("scip-java.properties").toFile - val copiedJars = outs.map { case (_, out) => out } // Build version consumed at runtime by BuildInfo.version (Kotlin). IO.write(propsFile, s"version=${version.value}\n") - propsFile +: copiedJars + propsFile +: outs.map(_._2) } .taskValue ) @@ -264,10 +261,6 @@ lazy val scipKotlinc = project name := "scip-kotlinc", moduleName := "scip-kotlinc", description := "A kotlinc plugin to emit SCIP information", - crossPaths := false, - autoScalaLibrary := false, - // Pin bytecode to major 55 so sbt-assembly's older ASM can shade it. - Compile / javacOptions ++= Seq("--release", "11"), kotlinVersion := V.kotlinVersion, kotlincJvmTarget := "1.8", kotlincOptions ++= Seq("-Xinline-classes", "-Xcontext-parameters"), @@ -353,8 +346,6 @@ lazy val scipKotlincMinimized = project .enablePlugins(KotlinPlugin) .settings( publish / skip := true, - crossPaths := false, - autoScalaLibrary := false, kotlinVersion := V.kotlinVersion, kotlincJvmTarget := "1.8", kotlinLib("stdlib"), @@ -441,34 +432,28 @@ lazy val scipKotlincMinimized = project .value ) -def minimizedSourceDirectory = - file("tests/minimized/src/main/java").getAbsoluteFile - -lazy val minimizedSettings = List[Def.Setting[_]]( - autoScalaLibrary := false, - (publish / skip) := true, - (publishLocal / skip) := true, - (run / fork) := true, - (Compile / unmanagedSourceDirectories) += minimizedSourceDirectory, - libraryDependencies ++= List("org.projectlombok" % "lombok" % "1.18.22"), - // Fork javac so it receives real file paths instead of sbt's `vf://` virtual-file URIs - // (see the comment on `scipKotlincMinimized` for the long story). - javaHome := Some(file(System.getProperty("java.home"))), - Compile / javacOptions ++= javacModuleOptions, - javacOptions += - List( - s"-Xplugin:scip", - s"-text:on", - s"-verbose", - s"-sourceroot:${(ThisBuild / baseDirectory).value}", - s"-targetroot:${(Compile / semanticdbTargetRoot).value}", - s"-randomtimestamp=${System.nanoTime()}" - ).mkString(" ") -) - lazy val minimized = project .in(file("tests/minimized/.j11")) - .settings(minimizedSettings, javaOnlySettings) + .settings( + publish / skip := true, + run / fork := true, + (Compile / unmanagedSourceDirectories) += + file("tests/minimized/src/main/java").getAbsoluteFile, + libraryDependencies += "org.projectlombok" % "lombok" % "1.18.22", + // Fork javac so it receives real file paths instead of sbt's `vf://` virtual-file URIs + // (see the comment on `scipKotlincMinimized` for the long story). + javaHome := Some(file(System.getProperty("java.home"))), + Compile / javacOptions ++= javacModuleOptions, + javacOptions += + List( + s"-Xplugin:scip", + s"-text:on", + s"-verbose", + s"-sourceroot:${(ThisBuild / baseDirectory).value}", + s"-targetroot:${(Compile / semanticdbTargetRoot).value}", + s"-randomtimestamp=${System.nanoTime()}" + ).mkString(" ") + ) .dependsOn(javacPlugin) def javacModuleOptions = List( @@ -483,8 +468,6 @@ lazy val buildTools = project .in(file("tests/buildTools")) .enablePlugins(KotlinPlugin) .settings( - crossPaths := false, - autoScalaLibrary := false, publish / skip := true, kotlinVersion := V.kotlinVersion, kotlincJvmTarget := "11", @@ -510,8 +493,16 @@ lazy val buildTools = project lazy val snapshots = project .in(file("tests/snapshots")) .settings( - javaOnlySettings, - javaTestSettings, + publish / skip := true, + Test / fork := true, + // Open the JDK-internal javac packages to the in-process javac the tests + // drive; on JDK 17+ this is required or the reflective access fails. + Test / javaOptions ++= javacModuleOptions.map(_.stripPrefix("-J")), + // Pin the JDK version embedded in stdlib SCIP symbols (e.g. `jdk 11 + // java/lang/String#`) so snapshots are stable across JDK 11/17/21. + Test / javaOptions += "-Dscip.jdk.version=11", + libraryDependencies += "com.github.sbt.junit" % "jupiter-interface" % + JupiterKeys.jupiterVersion.value % Test, Compile / mainClass := Some("tests.SaveSnapshots"), Compile / run / fork := true, Test / javaOptions ++= snapshotPathOptions.value, @@ -519,31 +510,6 @@ lazy val snapshots = project ) .dependsOn(cli) -lazy val javaOnlySettings = List[Def.Setting[_]]( - autoScalaLibrary := false, - incOptions ~= { old => - old.withEnabled(false).withApiDebug(true) - }, - crossPaths := false, - // Pin bytecode to major 55 so sbt-assembly's older ASM can shade it. - Compile / javacOptions ++= Seq("--release", "11") -) - -lazy val javaTestSettings = List[Def.Setting[_]]( - (publish / skip) := true, - autoScalaLibrary := false, - crossPaths := false, - Test / fork := true, - // Open the JDK-internal javac packages to the in-process javac the tests - // drive; on JDK 17+ this is required or the reflective access fails. - Test / javaOptions ++= javacModuleOptions.map(_.stripPrefix("-J")), - // Pin the JDK version embedded in stdlib SCIP symbols (e.g. `jdk 11 - // java/lang/String#`) so snapshots are stable across JDK 11/17/21. - Test / javaOptions += "-Dscip.jdk.version=11", - libraryDependencies += "com.github.sbt.junit" % "jupiter-interface" % - JupiterKeys.jupiterVersion.value % Test -) - // Runtime paths for the snapshot generator, passed as -D system properties. // Depending on `minimized/compile` here guarantees a fresh targetroot whenever // `snapshots/test` or `snapshots/run` evaluate javaOptions. From 5cb3b25677ede343358aeee6fa11a63fb8c5c00c Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 23 Jun 2026 14:18:54 +0200 Subject: [PATCH 6/9] Trim sbt metadata --- build.sbt | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/build.sbt b/build.sbt index 6a48ac152..0e84a58a1 100644 --- a/build.sbt +++ b/build.sbt @@ -33,22 +33,7 @@ inThisBuild( old.withEnabled(false).withApiDebug(true) }, licenses := - List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")), - developers := - List( - Developer( - "jupblb", - "Michal Kielbowicz", - "michal.kielbowicz@sourcegraph.com", - url("https://github.com/jupblb") - ), - Developer( - "chrapkowski-sg", - "Adam Chrapkowski", - "adam.chrapkowski@sourcegraph.com", - url("https://github.com/chrapkowski-sg") - ) - ) + List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")) ) ) @@ -152,8 +137,7 @@ lazy val scip = project JupiterKeys.jupiterVersion.value % Test ), (Compile / PB.targets) := - Seq(PB.gens.java(V.protobuf) -> (Compile / sourceManaged).value), - Compile / PB.protocOptions := Seq("--experimental_allow_proto3_optional") + Seq(PB.gens.java(V.protobuf) -> (Compile / sourceManaged).value) ) .dependsOn(scipShared) From fd0bca8454c27ad229fa475949d3deae61e2cb44 Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 23 Jun 2026 14:41:33 +0200 Subject: [PATCH 7/9] Fix CI version capture --- .github/workflows/ci.yml | 7 +++++-- build.sbt | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 979804052..8919952c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,8 +140,11 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v13 - run: | - nix develop .#jdk${{ matrix.java }} --command sbt cli/pack publishM2 publishLocal - SCIP_JAVA_VERSION="$(nix develop .#jdk${{ matrix.java }} --command sbt --error 'print cli/version')" + sbt_output="$(mktemp)" + nix develop .#jdk${{ matrix.java }} --command \ + sbt --error cli/pack publishM2 publishLocal 'print cli/version' | tee "$sbt_output" + SCIP_JAVA_VERSION="$(awk 'NF { value = $0 } END { print value }' "$sbt_output")" + test -n "$SCIP_JAVA_VERSION" printf 'SCIP_JAVA_VERSION=%s\n' "$SCIP_JAVA_VERSION" >> "$GITHUB_ENV" printf 'SCIP_JAVA_CLI=%s\n' "$PWD/scip-java/target/pack/bin/scip-java" >> "$GITHUB_ENV" diff --git a/build.sbt b/build.sbt index 0e84a58a1..15bf9249d 100644 --- a/build.sbt +++ b/build.sbt @@ -27,7 +27,7 @@ inThisBuild( PB.protocVersion := V.protobuf, autoScalaLibrary := false, crossPaths := false, - // Pin bytecode to major 55 so sbt-assembly's older ASM can shade it. + // Pin bytecode to major 55 so compiler plugins can run on Java 11. Compile / javacOptions ++= Seq("--release", "11"), incOptions ~= { old => old.withEnabled(false).withApiDebug(true) @@ -427,6 +427,8 @@ lazy val minimized = project // Fork javac so it receives real file paths instead of sbt's `vf://` virtual-file URIs // (see the comment on `scipKotlincMinimized` for the long story). javaHome := Some(file(System.getProperty("java.home"))), + // Keep minimized snapshots stable across JDK 11/17/21. + Compile / javacOptions ++= Seq("--release", "11"), Compile / javacOptions ++= javacModuleOptions, javacOptions += List( From 69b8e03ec790350e89fc3471bc52d6372847ca3d Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 23 Jun 2026 16:05:01 +0200 Subject: [PATCH 8/9] Filter sbt version output --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8919952c5..2bd1f1ede 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -143,7 +143,11 @@ jobs: sbt_output="$(mktemp)" nix develop .#jdk${{ matrix.java }} --command \ sbt --error cli/pack publishM2 publishLocal 'print cli/version' | tee "$sbt_output" - SCIP_JAVA_VERSION="$(awk 'NF { value = $0 } END { print value }' "$sbt_output")" + SCIP_JAVA_VERSION="$( + sed -E $'s/\x1B\[[0-9;?]*[ -/]*[@-~]//g' "$sbt_output" | + grep -E '^[0-9]+[.][0-9]+[.][0-9]+' | + tail -n 1 + )" test -n "$SCIP_JAVA_VERSION" printf 'SCIP_JAVA_VERSION=%s\n' "$SCIP_JAVA_VERSION" >> "$GITHUB_ENV" printf 'SCIP_JAVA_CLI=%s\n' "$PWD/scip-java/target/pack/bin/scip-java" >> "$GITHUB_ENV" From 77a61938522464f5adf6feddf151842c30373070 Mon Sep 17 00:00:00 2001 From: jupblb Date: Tue, 23 Jun 2026 20:47:27 +0200 Subject: [PATCH 9/9] Read version from pack metadata --- .github/workflows/ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2bd1f1ede..05dbf658a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -140,13 +140,10 @@ jobs: - uses: DeterminateSystems/magic-nix-cache-action@v13 - run: | - sbt_output="$(mktemp)" nix develop .#jdk${{ matrix.java }} --command \ - sbt --error cli/pack publishM2 publishLocal 'print cli/version' | tee "$sbt_output" + sbt --error cli/pack publishM2 publishLocal SCIP_JAVA_VERSION="$( - sed -E $'s/\x1B\[[0-9;?]*[ -/]*[@-~]//g' "$sbt_output" | - grep -E '^[0-9]+[.][0-9]+[.][0-9]+' | - tail -n 1 + sed -n 's/^version:=//p' scip-java/target/pack/VERSION )" test -n "$SCIP_JAVA_VERSION" printf 'SCIP_JAVA_VERSION=%s\n' "$SCIP_JAVA_VERSION" >> "$GITHUB_ENV"