diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9d39e56e..05dbf658 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 @@ -89,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 @@ -129,20 +123,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 @@ -160,9 +140,14 @@ 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 --error cli/pack publishM2 publishLocal + SCIP_JAVA_VERSION="$( + 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" + 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/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index ed93824e..eb37ca8f 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/.jvmopts b/.jvmopts deleted file mode 100644 index cc6fa202..00000000 --- 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 b6b7aabf..00000000 --- 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 0075655f..00000000 --- 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 f69c929b..a2c56b72 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/Dockerfile b/Dockerfile index 149a2e31..5af45242 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 68a611c2..b4478b81 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 f43b619a..15bf9249 100644 --- a/build.sbt +++ b/build.sbt @@ -1,19 +1,10 @@ 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 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,53 +21,25 @@ 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 := "-", PB.protocVersion := V.protobuf, + autoScalaLibrary := false, + crossPaths := false, + // 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) + }, 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")) ) ) 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 - } - // 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). @@ -84,7 +47,6 @@ lazy val scipShared = project .in(file("scip-shared")) .settings( moduleName := "scip-shared", - javaOnlySettings, libraryDependencies += "org.scip-code" % "scip-java-bindings" % V.scipBindings ) @@ -93,7 +55,6 @@ lazy val gradlePlugin = project .in(file("scip-gradle-plugin")) .settings( name := "scip-gradle", - javaOnlySettings, publish / skip := true, libraryDependencies ++= List( @@ -105,8 +66,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. Compile / compile / javacOptions += "-g", @@ -118,6 +77,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 @@ -155,9 +127,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, @@ -167,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) @@ -176,7 +145,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", @@ -203,14 +171,11 @@ 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, - 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 @@ -232,22 +197,17 @@ lazy val cli = project ), (Compile / resourceGenerators) += Def - .task[Seq[File]] { - val outs = ListBuffer.empty[(File, File)] + .task { 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( @@ -256,44 +216,13 @@ lazy val cli = project preserveLastModified = false, preserveExecutable = true ) - val props = new Properties() val propsFile = out.resolve("scip-java.properties").toFile - val copiedJars = outs.collect { 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.toList + propsFile +: outs.map(_._2) } - .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) @@ -316,10 +245,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"), @@ -340,9 +265,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 @@ -352,20 +276,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( @@ -420,8 +330,6 @@ lazy val scipKotlincMinimized = project .enablePlugins(KotlinPlugin) .settings( publish / skip := true, - crossPaths := false, - autoScalaLibrary := false, kotlinVersion := V.kotlinVersion, kotlincJvmTarget := "1.8", kotlinLib("stdlib"), @@ -446,11 +354,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 @@ -508,34 +416,30 @@ 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"))), + // Keep minimized snapshots stable across JDK 11/17/21. + Compile / javacOptions ++= Seq("--release", "11"), + 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( @@ -550,8 +454,6 @@ lazy val buildTools = project .in(file("tests/buildTools")) .enablePlugins(KotlinPlugin) .settings( - crossPaths := false, - autoScalaLibrary := false, publish / skip := true, kotlinVersion := V.kotlinVersion, kotlincJvmTarget := "11", @@ -577,8 +479,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, @@ -586,35 +496,9 @@ 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 -// (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( @@ -628,64 +512,3 @@ def snapshotPathOptions = Def.task { .getAbsolutePath}" ) } - -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" -) -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/flake.nix b/flake.nix index 82f697ad..24c755c8 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 7abe11a2..b098a7ed 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,16 +1,6 @@ -addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.14") -addSbtPlugin("se.marcuslonnberg" % "sbt-docker" % "1.11.0") +addSbtPlugin("org.xerial.sbt" % "sbt-pack" % "0.16") 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)